[R] How can i inhibit this work "Please select a CRAN mirror for use in this session "?
Dear Rusers, When i start R, there always the following work to do first, how should i cancel it? *--- Please select a CRAN mirror for use in this session ---* I don't know why it does so, maybe i have done something unintentionally. Thanks. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:[EMAIL PROTECTED] Website: www.statABC.com [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is there any good tools to facilitate us to create R functions?
Dear R users, We have some programs for the specific task in our research, but they were very commonly used. We want to make some functions for them, anybody can recommend any good tools to facilitate us to create R functions even without going deep into the theories of R functions ? Any suggestions or help are greatly appreciated. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:[EMAIL PROTECTED] Website: www.statABC.com [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Can I test if there are statistical significance between different rows in R*C table?
Dear Uwe Ligges, better good bad Goup1 16 71 37 Group2 0 4 61 Group3 1 6 57 My hypothesis is if the three groups,that is group1, group2,and group3, have the same distributions on coloumns? If not, which one is difference from which one? On 7/20/07, Uwe Ligges <[EMAIL PROTECTED]> wrote: > > > > zhijie zhang wrote: > > Dear friends, > > My R*C table is as follow: > > > > > > > > better > > > > good > > > > bad > > > > Goup1 > > > > 16 > > > > 71 > > > > 37 > > > > Group2 > > > > 0 > > > > 4 > > > > 61 > > > > Group3 > > > > 1 > > > > 6 > > > > 57 > > > >Can I test if there are statistical significant between Group1 and > > Group2, Group2 and Group3, Group1 and Group2, taking into the multiple > > comparisons? > > > So what is you hypothesis? Statistical significance of what it to be > tested? > > Uwe Ligges > > > > > The table can be set up using the following program: > > > > a<-matrix(data=c(16,71,37,0,4,61,1,6,57),nrow=3,byrow=TRUE) > > Thanks very much. > > > > > -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:[EMAIL PROTECTED] Website: www.statABC.com [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Can I test if there are statistical significance between different rows in R*C table?
Dear friends, My R*C table is as follow: better good bad Goup1 16 71 37 Group2 0 4 61 Group3 1 6 57 Can I test if there are statistical significant between Group1 and Group2, Group2 and Group3, Group1 and Group2, taking into the multiple comparisons? The table can be set up using the following program: a<-matrix(data=c(16,71,37,0,4,61,1,6,57),nrow=3,byrow=TRUE) Thanks very much. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:[EMAIL PROTECTED] Website: www.statABC.com [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] a little problem on selecting a subset from dataset A according to dataset B?
Dear Friends, I want to extract the records from A according to B, but the results are not correct because R says : The length of long object is not integer times on the length of short object. Anybody have met the same problem? How to do it correctly? length(A)=47 length(B)=6 A[A$coords.x1==B$X1,] #the program for the above task. I should get 6 records, but i only get former 4 records for the above reason. Thanks. The folloing shows dataset A and B. > A coords.x1 coords.x2 0 542250.89 3392404.1 1 538813.87 3388339.0 2 536049.19 3385821.6 3 533659.62 3383194.2 4 530642.30 3376834.9 5 529573.15 3378177.8 6 530853.82 3394838.8 7 541512.51 3394721.6 8 541479.33 3394877.8 9 538903.39 3395942.5 10 536019.95 3396286.1 11 538675.23 3384213.2 12 535127.95 3381255.4 13 533852.24 3378660.4 14 531360.91 3379273.8 15 539289.14 3375759.8 16 543410.51 3384353.1 17 543089.27 3388170.1 18 543274.03 3389919.2 19 543840.77 3392012.4 20 553383.55 3402401.8 21 554621.51 3397938.9 22 564096.42 3397524.4 23 567529.64 3398702.9 24 561798.76 3404864.0 25 562868.34 3405502.2 26 563145.22 3403192.1 27 562419.87 3404090.4 28 558321.85 3403879.9 29 567050.74 3404973.1 30 570609.70 3408742.4 31 556777.57 3397858.0 32 531353.38 3368596.6 33 533513.50 3372749.3 34 537543.19 3364284.8 35 538779.41 3368224.8 36 525930.09 3374067.7 37 522990.85 3369213.1 38 528826.37 3359019.0 39 533865.85 3362595.4 40 531200.25 3365053.0 41 551054.10 3377181.3 42 546974.19 3369284.8 43 572315.59 3359541.1 44 562703.63 3355173.4 45 558959.31 3357804.4 46 558531.39 3361741.1 > B X1X2 1 542250.89 3392404.1 2 541512.51 3394721.6 3 541479.33 3394877.8 4 538903.39 3395942.5 5 543274.03 3389919.2 6 543840.77 3392012.4 -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:[EMAIL PROTECTED] Website: www.statABC.com [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help on fisher.test(stats)?
Dear friends, My dataset have many zeros, so i must use fisher exact test . Unfortunately, the fisher.test(stats) function fail to do it. Anybody knows how to do the fisher exact test with many zeros in the dataset? My dataset is: a<-matrix(c(0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,1,1,0,2,1,5,1,1,6,4,4,1,17,2,8,5,7,1,1,24,3,6,1,1,3,2,16,7,4,0,2,4,0,17,0,1,0,0,0,1,2),nrow=8,byrow=TRUE) data.frame(a) b<-a[,-7] as.matrix(b) c<-as.matrix(b) > c [,1] [,2] [,3] [,4] [,5] [,6] [1,]010000 [2,]010000 [3,]011021 [4,]116441 [5,]285711 [6,]361132 [7,]740240 [8,]010001 > fisher.test(c,workspace=20) ´íÎóÓÚfisher.test(c, workspace = 2e+17) : Íâ½Óº¯Êýµ÷ÓÃʱ²»ÄÜÓÐNA(arg10) ´ËÍâ: Warning message: Ç¿ÖƸıä¹ý³ÌÖвúÉúÁËNA Any suggestion or help are greatly appreciated. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:[EMAIL PROTECTED] Website: www.statABC.com [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How should i get the quantile 2.5 % and 97.5% in each row of a matrix?
Dear friends, I need the get the 2.5% and 97.5% quantile from each row of a matrix, how should i get it? BTW, i can get the min/max value from each row of a matrix, using the following programs, is there an easy function to do it? simmin<-matrix(NA,nrow=47,ncol=1) for (i in 1:47) { simmin[i,]<-min(datas[i,]) } Thanks for your help. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:[EMAIL PROTECTED] Website: www.statABC.com [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R and S-Plus got the different results of principal component analysis from SAS, why?
Dear Rusers, I have met a difficult problem on explaining the differences of principal component analysis(PCA) between R,S-PLUS and SAS/STATA/SPSS, which wasn't met before. Althought they have got the same eigenvalues, their coeffiecients were different. First, I list my results from R,S-PLUS and SAS/STATA/SPSS, and then show the original dataset, hoping sb. to try and explain it. SAS,STATA,and SPSS have the same results, so i put them together. From their results, we see that the absolute values of coeffiecient are same, but PC1,PC2,PC4,PC5 and PC6 in R have the opposite sign on the coeffiecnts contrast with SAS, and PC4,PC5 in S-PLUS have the opposite sign on the coeffiecnts contrast with SAS. Curiously, I got the same results amont all these software using my another dataset. *R's results of PCA:* *PC1* *PC2* PC3*PC4**PC5 ** PC6* X1 -0.5152569 0.20264489 -0.2338786 0.2350876 -0.205 -0.736298528 X2 -0.5197856 0.08989351 -0.2068260 0.3737667 -0.3187746 0.661548469 X3 -0.5148033 0.15820613 -0.0590627 -0.3210113 0.7693052 0.107616466 X4 -0.3535798 0.08105168 0.7317188 -0.4350752 -0.3790772 0.003088541 X5 -0.1868691 -0.67517084 -0.4397442 -0.5119015 -0.2314833 -0.014886524 X6 -0.1984241 -0.68073489 0.4126112 0.5006500 0.2606219 -0.091682326 pca<-read.csv('D:\pca.csv',sep=',',header=T) attach(pca) pcacomp <- prcomp(pca[,-1], retx=TRUE, center=TRUE,scale.= TRUE,tol=0.0001) *S-Plus's results of PCA:* pc1 pc2 pc3 *pc4pc5* pc6 X1 0.5153 -0.2026 -0.2339 0.2351 -0.2033 0.7363 X2 0.5198 -0.0899 -0.2068 0.3738 -0.3188 -0.6615 X3 0.5148 -0.1582 -0.0591 -0.3210 0.7693 -0.1076 X4 0.3536 -0.0811 0.7317 -0.4351 -0.3791 -0.0031 X5 0.1869 0.6752 -0.4397 -0.5119 -0.2315 0.0149 X6 0.1984 0.6807 0.4126 0.5007 0.2606 0.0917 *SAS/STATA/SPSS's results of PCA:* PC1 PC2 PC3 PC4 PC5 PC6 X1 0.515257 -.202645 -.233879 -.235088 0.203334 0.736299 X2 0.519786 -.089894 -.206826 -.373767 0.318775 -.661548 X3 0.514803 -.158206 -.059063 0.321011 -.769305 -.107616 X4 0.353580 -.081052 0.731719 0.435075 0.379077 -.003089 X5 0.186869 0.675171 -.439744 0.511902 0.231483 0.014887 X6 0.198424 0.680735 0.412611 -.500650 -.260622 0.091682 My dataset used in the above results is : X1 X2 X3 X4 X5 X6 173.28 93.62 60.1 86.72 38.97 27.51 172.09 92.83 60.38 87.39 38.62 27.82 171.46 92.73 59.74 85.59 38.83 27.46 170.08 92.25 58.04 85.92 38.33 27.29 170.61 92.36 59.67 87.46 38.38 27.14 171.69 92.85 59.44 87.45 38.19 27.1 171.46 92.93 58.7 87.06 38.58 27.36 171.6 93.28 59.75 88.03 38.68 27.22 171.6 92.26 60.5 87.63 38.79 26.63 171.16 92.62 58.72 87.11 38.19 27.18 170.04 92.17 56.95 88.08 38.24 27.65 170.27 91.94 56 84.52 37.16 26.81 170.61 92.5 57.34 85.61 38.52 27.36 171.39 92.44 58.92 85.37 38.83 26.47 171.83 92.79 56.85 85.35 38.58 27.03 171.36 92.53 58.39 87.09 38.23 27.04 171.24 92.61 57.69 83.98 39.04 27.07 170.49 92.03 57.56 87.18 38.54 27.57 169.43 91.67 55.22 83.87 38.41 26.6 168.57 91.4 55.96 83.02 38.74 26.97 170.43 92.38 57.87 84.87 38.78 27.37 169.88 91.89 56.87 86.34 38.37 27.19 167.94 90.91 55.97 86.77 38.17 27.16 168.82 91.3 56.07 85.87 37.61 26.67 168.02 91.26 55.28 85.63 39.66 28.07 167.87 90.96 55.79 84.92 38.2 26.53 168.15 91.5 54.56 84.81 38.44 27.38 168.99 91.52 55.11 86.23 38.3 27.11 Any help or suggestions are greatly appreciated. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is it the PPS samples i needed in R?
Dear friends, I want to do a unequal probability sampling, that is, Probability Proportionate to size, Is it right for the following programs? Say my original dataset is: ID Population 1 100 2 200 3 300 IF the population is large ,then the corresponding ID has the large Probability to be selected. sample(A$ID, size=2, replace = FALSE, prob = A$population) #suppose the dataset name is A. Is it the PPS samples i needed ? Any suggestions are greatly welcome. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] errors when setting up R2.4.0-win32.exe
Dear Ruser, Today, i download R2.4.0-win32.exe, but can't set it up successfully. The error informaiton is : *"0x38e4"memory quoted by "ox6c7f22b3" can't be "readonly".* My operating system in WindowXP. Where goes wrong? Thanks. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] questions on adding reference line?
Dear Ruser, I use abline() function to add the reference line successfully, but i can't display the values corresponding to the reference line on the x/y axis, anybody knows how to display it? *My simulated programs:* y<-rnorm(50) plot(x,y) abline(v=0.5) *#my question is how to display x=0.5 in the x axis?* Thanks in advance. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot questions?-errors in persp(x1, x2, y) and contour(x1, x2, y)
Dear Uwe Ligges , I still can't finish it. *> aa* #my data x1 x2 y 50.05 6 4.4180 10.50 3 2.6979 40.50 9 2.9000 70.95 6 2.6230 80.95 6 2.9078 90.95 6 2.6727 31.40 3 2.4203 21.40 9 2.5329 6 1.85 6 2.4867 *> attach(aa)* *> persp(x1,x2,y* error in persp.default(x1, x2, y) : increasing 'x' and 'y' values expected *> contour(x1,x2,y)* error in contour.default(x1, x2, y) : increasing 'x' and 'y' values expected What's the problem? And could u recommend a book for me? Thanks again. On 11/7/06, Uwe Ligges <[EMAIL PROTECTED]> wrote: > > > > zhijie zhang wrote: > > Dear Rusers, > > I want to know which function in R can perform the following tasks: > > 1.surface-data grid(x,y,z) #which could be done in splus, the name was > from > > splus's options of graph > > 2. contourplot(x,y,z) #which could be done in splus > > By the way, where can i find some useful materials to learn to plot > > 3-dimensionel graphs? > > Thanks! > > > > 1. persp() > 2. contour() > 3. E.g., look into a good book about R. > > Uwe Ligges > -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plot questions?
Dear Rusers, I want to know which function in R can perform the following tasks: 1.surface-data grid(x,y,z) #which could be done in splus, the name was from splus's options of graph 2. contourplot(x,y,z) #which could be done in splus By the way, where can i find some useful materials to learn to plot 3-dimensionel graphs? Thanks! -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plots questions?
Dear friends, I have three variables ,x,y and z, and i want to get two plots: 1.three-dimensionel plot: z is the vertical axis, x and y is on the same horizontal plane; 2.contour plot:x is the horizontal axis, and y is vertical axis, and z is used to plot the contour line. I can't finish it ,anybody can help me ? Thanks in advance. -- With Kind Regards, Zhi Jie,Zhang [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to find further informations on specific options?
Dear friends, When i read the R-help , i often find the following case: e.g.:surf.gls(np, covmod, x, y, z, nx = 1000, ...) #Package Spatial: Arguments: covmod: function to evaluate covariance or correlation function * ...: parameters for 'covmod'* How should i find the further information on "*...: parameters for 'covmod'*" ? I use the ?covmod, but can't find the information. Could anybody give me the general method to do so? -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] gamma distribution don't allow negative value in GLMs?
Dear friends, when i use glm() to fit my data, i use glm(formula = snail ~ vegtype + mhveg + humidity + elevation + soiltem, *family = Gamma(link = inverse),* data =a,)) It shows: error in eval(expr, envir, enclos) : *gamma distribution don't allow negative value*. But i use result<-glm(formula = snail ~ vegtype + mhveg + humidity + elevation + soiltem, family = poisson, data =a) #this works In fact , there isn't any negative value in my dataset, who can tell me the reason? Thanks very much! I copy my data here so you can check it: vegtype mhveg humidity soiltem elevation snail 1 diluo 35.0 0.27985121.1 low 162 2 diluo 25.0 0.31609223.1 low 113 3 yuhao 35.0 0.29723821.7 low 105 4 huanghuacai 1.5 0.31068723.1 low 5 5 huanghuacai 2.0 0.26786828.3 low 1 6 yuhao 25.0 0.29013521.9 low10 7 huanghuacai 1.0 0.28520727.7 low 6 8 huanghuacai 2.0 0.25297328.3 low 1 9 huanghuacai 1.5 0.2728.1 low 1 10 huanghuacai 2.5 0.3029.1 low 1 11 huanghuacai 2.0 0.29615429.1 low 0 12 huanghuacai 2.0 0.30287427.5 low 3 13 huanghuacai 1.5 0.30149928.9 low 0 14 huanghuacai 3.0 0.29151330.3 low 1 15 huanghuacai 1.0 0.27343831.1 low 3 16 huanghuacai 1.5 0.29011627.9 low19 17 huanghuacai 2.5 0.19893231.9 low 0 18 huanghuacai 2.0 0.3930.5 high 4 19 huanghuacai 2.5 0.28259530.7 high 0 20 huanghuacai 1.0 0.26609724.7 high14 21yuhao 30.0 0.24051626.9 high51 22yuhao 35.0 0.22754126.7 high84 23yuhao 20.0 0.25283328.3 low30 24diluo 40.0 0.30303027.9 low91 25hucao 80.0 0.30386724.5 low 114 26diluo 25.0 0.33494826.7 low 115 27hucao 60.0 0.30689726.5 low23 28hucao 75.0 0.31446525.7 low43 29yuhao 30.0 0.25178326.1 low77 30diluo 10.0 0.2826.1 low62 31yuhao 25.0 0.29171626.1 low78 32hucao 90.0 0.28880024.5 low35 33diluo 25.0 0.33783026.3 high75 34yuhao 13.0 0.29659927.7 high23 35hucao 70.0 0.27949826.3 high 116 36diluo 3.0 0.28148128.1 high25 37hucao 70.0 0.29600023.7 high83 38diluo 10.0 0.27266227.7 low56 39hucao 70.0 0.28979625.3 high 112 40diluo 5.0 0.33971627.9 high84 41yuhao 35.0 0.23142724.9 high88 42hucao 80.0 0.27381024.1 high 134 43yuhao 40.0 0.27278925.1 high53 44yuhao 45.0 0.22603625.1 high88 45yuhao 55.0 0.28549523.9 high76 46hucao 80.0 0.25218523.9 high 106 47diluo 15.0 0.28993324.5 high 194 48hucao 95.0 0.26175623.1 high35 49hucao 55.0 0.23981924.7 high21 50hucao 75.0 0.25430723.9 high41 51 huanghuacai 1.0 0.28643223.7 low18 52 huanghuacai 2.0 0.30134223.1 low 2 53 huanghuacai 2.0 0.36956523.3 low 5 54 huanghuacai 1.5 0.24583324.3 low 4 55 huanghuacai 1.0 0.31567924.1 low 4 56 huanghuacai 2.5 0.29612423.7 low 4 57 huanghuacai 2.0 0.31266725.7 low 3 58 huanghuacai 3.0 0.30087025.7 low 0 59 huanghuacai 2.0 0.30374326.5 low 2 60 huanghuacai 1.0 0.26979925.3 low 7 61hucao 75.0 0.28125022.5 low14 62yuhao 35.0 0.35035023.3 low63 63hucao 65.0 0.30454522.7 low17 64diluo 7.0 0.31005624.9 low45 65hucao 80.0 0.28800022.9 low27 66hucao 80.0 0.28421122.7 low46 67diluo 25.0 0.28137923.5 low 161 68hucao 80.0 0.29053323.3 low 117 69yuhao 27.0 0.31656824.1 low 106 70yuhao 28.0 0.28515625.1 low82 71yuhao 30.0 0.2724.5 low55 72hucao 85.0 0.29034523.9 low54 73yuhao 35.0 0.31578924.1 low81 74diluo 15.0 0.28659828.3 low 102 75yuhao 45.0 0.31421124.1 low85 76yuhao 25.0 0.26879425.1 low63 77hucao 80.0 0.27569123.9 low59 78hucao 100.0 0.31661424.1 low46 79yuhao 40.0 0.33668325.5 low70 80diluo 20.0 0.27087426.1 high 167 81
Re: [R] sort question in a dataset?
*Richard M. Heiberger* , You have showed a detailed informaton on order, but it seems that there's a little difference between my task and your suggestions. I'd like to give a clear example to show my task: x <- c(2, 9, 18, 3, 2) y <- c(2,9,8,9,8) z <- c(21,5,5,19,7) a <- cbind(x, y, z) #dataset a x y z [1,] 2 2 21 [2,] 9 9 5 [3,] 18 8 5 [4,] 3 9 19 [5,] 2 8 7 aa <- a[order(a[,"y"], decreasing=TRUE),] aaa <- aa[order(aa[,"x"], decreasing=FALSE),] aaa x y z [1,] 2 8 7 [2,] 2 2 21 [3,] 3 9 19 [4,] 9 9 5 [5,] 18 8 5 But i hope to get the following results: x y z [1,] 3 9 19 [2,] 9 9 5 [3,] 2 8 7 [4,] 18 8 5 [5,] 2 2 21 *That's to say to sort the dataset with decreasing y and ascending x simultaneously*. BTW, what's the main difference between order() and sort()? I can't find some simple introduction on their differnce. Thanks very much! On 10/15/06, Richard M. Heiberger <[EMAIL PROTECTED]> wrote: > > > ?order > > x <- c(2, 9, 18, 3, 2) > > y <- c(2,5.6,5,9,8) > > z <- c(21,5,5,19,7) > > a <- cbind(x, y, z) > > a > x y z > [1,] 2 2.0 21 > [2,] 9 5.6 5 > [3,] 18 5.0 5 > [4,] 3 9.0 19 > [5,] 2 8.0 7 > > aa <- a[order(a[,"y"], decreasing=TRUE),] > > aaa <- aa[order(aa[,"x"], decreasing=FALSE),] > > aaa > x y z > [1,] 2 8.0 7 > [2,] 2 2.0 21 > [3,] 3 9.0 19 > [4,] 9 5.6 5 > [5,] 18 5.0 5 > > > > a$y doesn't work because $ subscripting requires a data.frame. > cbind creates an ordinary matrix. This works with a data.frame. > > a <- data.frame(x, y, z) > > aa <- a[order(a$y, decreasing=TRUE),] > > aaa <- aa[order(aa$x, decreasing=FALSE),] > > Please use spaces for legibility on both sides of the assignment > arrow and after a comma. > > If you want all columns ascending (or descending), then you could do it in > one step > > <- a[order(a$x, a$y), ] > > See also the example in ?order > ## Suppose we wanted descending order on y. A simple solution is > rbind(x,y,z)[, order(x, -y, z)] > -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sort question in a dataset?
Dear friends, I want to sort a dataset according to one or two variables in the dataset, i thought sort could do it , but failed. e.g. x <- c(2, 9, 18, 3, 2) y<-c(2,5.6,5,9,8) z<-c(21,5,5,19,7) a<-cbind(x,y,z) a x y z [1,] 2 2.0 21 [2,] 9 5.6 5 [3,] 18 5.0 5 [4,] 3 9.0 19 [5,] 2 8.0 7 I want to sort dataset a according to ascending x and descending y, How to accomplish it? BTW, sort(a$x) can't works and it shows"null", why is it? Any suggestions are welcome! -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is there a function in R to evaluate the adjusted AIC or other statistc where overdispersion existed in GLMs?
Dear friends, As we all know, the usual model selection criteria(e.g.deviance,AIC...) in GLMs isn't very good for selecting the best model when overdispersion exist, so we need to adjust the corresponding statistic,see(Fitzmaurice,G.M. (1997) Model selection with overdispersed data, The Statistician,46(1):81-91.). Is there a function in R to evaluate the adjusted AIC or other statistc where overdispersion existed in GLMs? How should i do in that case? Thanks in advance. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get the variance-covariance matrix/information of alpha and beta after fitting a GLMs?
Dear friends, Both vcov(your.model) and summary(B)$cov.unscaled,summary(B)$cov.scaled works, and vcov is the function that i'm looking for. Thanks very much! - with kind regards zhijie [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to get the variance-covariance matrix/information of alpha and beta after fitting a GLMs?
Dear friends, After fitting a generalized linear models ,i hope to get the variance of alpha,variance of beta and their covariance, that is , the variance-covariance matrix/information of alpha and beta , suppose *B* is the object of GLMs, i use attributes(B) to look for the options ,but can't find it, anybody knows how to get it? > attributes(B) $names [1] "coefficients" "residuals" "fitted.values" "effects" [5] "R" "rank" "qr" "family" [9] "linear.predictors" "deviance" "aic" " null.deviance" [13] "iter" "weights" "prior.weights" " df.residual" [17] "df.null" "y" "converged" "boundary" [21] "model" "call" "formula" "terms" [25] "data" "offset""control" "method" [29] "contrasts" "xlevels" $class [1] "glm" "lm" I appreciate any help/suggestions. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help on plots
*Marc Schwartz ,* ** Method2 is what i need, and they are good answers. A little more question is how to add the legend to the plot? legend() may do it,but i fail to add them. Thanks again. with kind regards zhijie zhang On 9/29/06, Marc Schwartz (via MN) <[EMAIL PROTECTED]> wrote: > > On Thu, 2006-09-28 at 23:55 +0800, zhijie zhang wrote: > > Dear friends, > > I met a problem on plotting. > > My dataset is : > > yearMHBC LHBC MHRC LURC > > 1993 11.75 4.50 0.43 0.46 > > 19947.25 1.25 0.35 0.51 > > 19958.67 2.17 0.54 0.44 > > 1996 2.67 1.33 0.78 0.47 > > 1997 3.42 4.92 0.69 0.48 > > 1998 1.92 3.08 0.72 0.54 > > 1999 2.33 2.58 0.74 0.41 > > 2000 5.75 4.50 0.45 0.50 > > 2001 3.75 4.42 0.52 0.47 > > 2002 2.33 1.83 0.58 0.45 > > 2003 0.25 2.83 0.50 0.39 > > I want to get a plot -line with scatters, the requirement is : > > x-axis is year; > > two y-axis: > > y1 corresponds to MHBC and LHBC; > > y2 corresponds to MHRC and LURC; > > hope to use different symbols to differentiate the MHBC,LHBC,MHRC > and LURC. > > > > The following is my program, but very bad ,: > > *plot(a$year,a$MHBC,type='b') #line1 > > par(new=T) > > plot(a$year,a$LHBC,type='b') #line2 > > par(new=T) > > plot(a$year,a$MHRC,type='b') #line3 > > par(new=T) > > plot(a$year,a$LURC,type='b') #line4 > > axis(4, at=pretty(range(a$MHRC)))* > > In the figure, the labels and scales of X-axis are vague, the scale of > > y-axis is not very good. > > The better figure should be like the line1 and 2 are in the upper, and > line3 > > and 4 are in the bottom. > > Any suggestion are welcome! > > It's not entirely clear to me what you want, so let me offer three > possibilities. > > > 1. Do all four lines in a single plot with a common y axis: > > matplot(a$year, a[, -1], type = "o", pch = 15:18) > > > > 2. Do all four lines in a single plot with the first two having a > separate left hand y axis and the second two having a separate right > hand y axis: > > # Draw the first pair of lines > matplot(a$year, a[, 2:3], type = "o", pch = c(19, 20), >lty = "solid", ann = FALSE) > > # Get the current plot region boundaries > usr <- par("usr") > > # Get the range of the second set of columns > range.y2 <- range(a[, 4:5]) > > # Change the plot region y axis range for the second > # set of columns. Extend them by 4% as per the default > par(usr = c(usr[1], usr[2], >range.y2[1] * 0.96 , range.y2[2] * 1.04)) > > # Add the second pair of lines > matlines(a$year, a[, 4:5], type = "o", pch = c(15, 18), > lty = "dashed", col = c("blue", "green")) > > # Add the second y axis > axis(4) > > > > 3. Do the first two lines in an upper plot and the second two lines in a > lower plot, each has its own y axis range: > > # Set plot region to have two rows > par(mfrow = c(2, 1)) > > # Adjust the plot margins > par(mar = c(2, 5, 2, 2)) > > # Draw the first pair of lines > matplot(a$year, a[, 2:3], type = "o", pch = c(19, 20), >lty = "solid", ylab = "First Pair") > > > par(mar = c(3, 5, 2, 2)) > > # Add the second pair of lines > matplot(a$year, a[, 4:5], type = "o", pch = c(15, 18), >lty = "dashed", col = c("blue", "green"), >ylab = "Second Pair") > > > > See ?matplot, ?par and ?points for more information. > > HTH, > > Marc Schwartz > > > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help on plots
Dear friends, I met a problem on plotting. My dataset is : yearMHBC LHBC MHRC LURC 1993 11.75 4.50 0.43 0.46 19947.25 1.25 0.35 0.51 19958.67 2.17 0.54 0.44 1996 2.67 1.33 0.78 0.47 1997 3.42 4.92 0.69 0.48 1998 1.92 3.08 0.72 0.54 1999 2.33 2.58 0.74 0.41 2000 5.75 4.50 0.45 0.50 2001 3.75 4.42 0.52 0.47 2002 2.33 1.83 0.58 0.45 2003 0.25 2.83 0.50 0.39 I want to get a plot -line with scatters, the requirement is : x-axis is year; two y-axis: y1 corresponds to MHBC and LHBC; y2 corresponds to MHRC and LURC; hope to use different symbols to differentiate the MHBC,LHBC,MHRC and LURC. The following is my program, but very bad ,: *plot(a$year,a$MHBC,type='b') #line1 par(new=T) plot(a$year,a$LHBC,type='b') #line2 par(new=T) plot(a$year,a$MHRC,type='b') #line3 par(new=T) plot(a$year,a$LURC,type='b') #line4 axis(4, at=pretty(range(a$MHRC)))* In the figure, the labels and scales of X-axis are vague, the scale of y-axis is not very good. The better figure should be like the line1 and 2 are in the upper, and line3 and 4 are in the bottom. Any suggestion are welcome! -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 [EMAIL PROTECTED] Dept. of Epidemiology,school of public health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] what's wrong with my simulation programs on logistic regression
Thanks to *Prof Brian Ripley* and *Dimitris Rizopoulos .* Then it should be different for a linear model,e.g.y=x1+x2+...+x8 In logistic regression model,the y should be : data$y <- rbinom(length(p), 1, p) But in linear model, data$y<-x1+x2+...+x8+error, error~N(0,variance), right? It seems different between them(or it's also wrong for my simulated linear model),i'm not very clear about them,thanks for a little more explanations on them. On 8/31/06, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > > On Thu, 31 Aug 2006, zhijie zhang wrote: > > > Dear friends, > > I'm doing a simulation on logistic regression model, but the programs > can't > > work well,please help me to correct it and give some suggestions. > > My programs: > > data<-matrix(rnorm(400),ncol=8) #sample size is 50 > > data<-data.frame(data) > > names(data)<-c(paste("x",1:8,sep="")) #8 independent variables,x1-x8; > > #logistic regression model is logit(y)=x1+x2+x3+x4+x5+x6+x7+x8 > > Rather it is logit(p) = ..., and y ~ binomial(1, p) > > There is a different sort of 'logistic regression' with > > y = exp(eta)/(1+exp(eta)) + epsilon > > but you fit that by nls, not glm. > > > > data$y<-exp(data$x1+data$x2+data$x3+data$x4+data$x5+data$x6+data$x7+data$x8)/(1+(data$x1+data$x2+data$x3+data$x4+data$x5+data$x6+data$x7+data$x8)) > > You need exp()/(1+exp()), and the second exp is missing. > > Once you have p, you can use data$y <- rbinom(length(p), 1, p) > > > logist<-glm(y~.,family=binomial(),data=simdata) > > *Warning messages:* > > 1: algorithm can't converge in: glm.fit(x = X, y = Y, weights = weights, > > start = start, etastart = etastart, > > 2: the probability is 0 or 1 in: glm.fit (x = X, y = Y, weights = > weights, > > start = start, etastart = etastart, > > You do not have a Bernoulli response: it often helps to look at your > simulated data to see if it makes sense (just as you would look at real > data, I hope). > > -- > Brian D. Ripley, [EMAIL PROTECTED] > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UKFax: +44 1865 272595 > -- With Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] what's wrong with my simulation programs on logistic regression
Forgot to add my thinkings: I think it over and think that the problem may be the argument(data$y<-exp(data$x1+data$x2+data$x3+data$x4+data$x5+data$x6+data$x7+data$x8)/(1+(data$x1+data$x2+data$x3+data$x4+data$x5+data$x6+data$x7+data$x8)) ),which maybe not correctly set for my model:logit(y)=x1+x2+x3+x4+x5+x6+x7+x8, Thanks very much! On 8/31/06, zhijie zhang <[EMAIL PROTECTED]> wrote: > > Dear friends, > I'm doing a simulation on logistic regression model, but the programs > can't work well,please help me to correct it and give some suggestions. > My programs: > data<-matrix(rnorm(400),ncol=8) #sample size is 50 > data<-data.frame(data) > names(data)<-c(paste("x",1:8,sep="")) #8 independent variables,x1-x8; > #logistic regression model is logit(y)=x1+x2+x3+x4+x5+x6+x7+x8 > data$y<-exp(data$x1+data$x2+data$x3+data$x4+data$x5+data$x6+data$x7+data$x8)/(1+(data$x1+data$x2+data$x3+data$x4+data$x5+data$x6+data$x7+data$x8)) > > logist<-glm(y~.,family=binomial(),data=simdata) > *Warning messages:* > 1: algorithm can't converge in: glm.fit(x = X, y = Y, weights = weights, > start = start, etastart = etastart, > 2: the probability is 0 or 1 in: glm.fit (x = X, y = Y, weights = weights, > start = start, etastart = etastart, > -- > With Kind Regards, > Zhi Jie,Zhang ,PHD > Department of Epidemiology > School of Public Health > Fudan University > -- With Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] what's wrong with my simulation programs on logistic regression
Dear friends, I'm doing a simulation on logistic regression model, but the programs can't work well,please help me to correct it and give some suggestions. My programs: data<-matrix(rnorm(400),ncol=8) #sample size is 50 data<-data.frame(data) names(data)<-c(paste("x",1:8,sep="")) #8 independent variables,x1-x8; #logistic regression model is logit(y)=x1+x2+x3+x4+x5+x6+x7+x8 data$y<-exp(data$x1+data$x2+data$x3+data$x4+data$x5+data$x6+data$x7+data$x8)/(1+(data$x1+data$x2+data$x3+data$x4+data$x5+data$x6+data$x7+data$x8)) logist<-glm(y~.,family=binomial(),data=simdata) *Warning messages:* 1: algorithm can't converge in: glm.fit(x = X, y = Y, weights = weights, start = start, etastart = etastart, 2: the probability is 0 or 1 in: glm.fit (x = X, y = Y, weights = weights, start = start, etastart = etastart, -- With Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to complete this task on data management
Dear friends, When i clean my dataset , i met a difficulty suppose my data set is : *> data<-data.frame(x=c(1:5,1,2,3)) > data x 1 1 2 2 3 3 4 4 5 5* 6 1 7 2 8 3 Now i need to add the data which are less than 3.5 at the bottom, not including the top data, so the results should be : x 1 1 2 2 3 3 4 4 5 5 *6 6* I tried to use " data[data$x>3.5,]" to do it , but it also delete the first several numbers,* How to finish it ?* Thanks very much. -- Kind Regards, Zhi Jie,Zhang [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] fit the series data
Dear friends, suppose my dataset *xy* : xy 1 5 2 3 5 6 6 8 -generated the data-- x<-c(1,2,5,6) y<-c(5,3,6,8) xy<-data.frame(x,y) --- I want to fit the gap in x with the corresponding y=0, I use the following programs to generate a new dataset *a*: a<-matrix(c(seq(1,6),rep(0,6)),ncol=2) a<-data.frame(a) names(a)<-c('i','x') > a i x 1 0 2 0 3 0 4 0 5 0 6 0 - *if(a$i=xy$x) a$x<-xy$y* # hope to replace the corresponding x-values in a with xy$y, but failed. Anybody can tell me how to finish the task on fill the series data? *My expected data should be:* * 1 5 2 3 3 0 4 0 5 6 6 8* Thanks a lot! -- Kind Regards, Zhi Jie,Zhang [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to the p-values or t-values from the lm's results
Dear friends, After running the lm() model, we can get summary resluts like the following: Coefficients: Estimate Std. Error t value Pr(>|t|) x1 0.115620.10994 1.052 0.2957 x2 -0.138790.09674 -1.435 0.1548 x3 0.010510.09862 0.107 0.9153 x4 0.141830.08471 1.674 0.0975 . x5 0.189950.10482 1.812 0.0732 . x6 0.248320.10059 2.469 0.0154 * x7 -0.044250.11008 -0.402 0.6886 x8 0.051460.10290 0.500 0.6182 - **the program maybe : data<-matrix(rnorm(900),ncol=9) #9variables,1dependent var,8independent data<-data.frame(data) names(data)<-c('y','x1','x2','x3','x4','x5','x6','x7','x8') logr<-lm(y~x1+x2+x3+x4+x5+x6+x7+x8-1,data) a<-summary(logr) Could i extract the p-values or t-values from the a$Coefficients, i searched the attributes(a), but don't find the options,how to do that? Thanks very much! -- Kind Regards, Zhi Jie,Zhang , [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to link matrix with the variables
Dear friends, Suppose the correlation matrix of x1-x3 is as follows: x1 x2 x3 x1 1 x2 0.51 x3 0.6 0.41 1.First, to generate the matrix of x1-x3 in R; 2.to get the random number: x1<-rnorm(10), is it enough to generate only the x1-values? Do i need to generate x2 and x3? 3. y=x1+2*x2+3*x3 , to generate the y-values; Thanks very much! -- Kind Regards, Zhi Jie,Zhang [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to generate this simulation dataset in R
Dear Rusers, I want to compare the different methods of variable selction in linear/logistic regression, so i want to generate simulated datasets, how to do that? e.g. response variable:y independent variables:x1-x4 residual item:e the theoretical formula is: y=2.1+0.1*x1+0.2*x2 x3,x4 are not related with y How should i do that? Thanks very much! !!SOS!! -- Kind Regards, Zhi Jie,Zhang [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to use the EV AND condEV from BMA's results?
Dear friends, In R, the help of "bic.glm" tells the difference between postmean(the posterior mean of each coefficient from model averaging) and condpostmean(the posterior mean of each coefficient conditional on the variable being included in the model), But it's still unclear about the results explanations, and the artile of Rnews in 2005 on BMA still don't give more detail on it. Suppose my results of logistic regression analyzed by bic.glm (BMA) as follows:(dataset is birthwt(MASS) and i include the interaction) p!=0 EV SD condEV cond SDmodel 1 model 2 model 3 model 4model 5 Intercept 100 0.1841 1.2204 0.1841.2201.017 1.175-0.853-1.057 0.532 age17.8 -0.0113 0.0285 -0.0630.036 . . . . -0.071 lwt 50.0 -0.0079 0.0093 -0.016 0.007 -0.017- 0.017 . . . smokeTRUE 9.5 0.0469 0.1798 0.4960.345 . . . . . ptdTRUE 99.41.5161 0.4751 1.526 0.461 1.407 1.596 1.732 1.463 1.608 htTRUE54.4 0.9477 1.02691.742 0.7441.894 1.930 . . . uiTRUE13.30.0976 0.2987 0.7310.453 . . . . . ftv 12.3 .1-0.0257 0.5117 -0.209 2.438. . -0.867 . . .2+0.7470 2.1277 6.0813.371. .6.024 . . age.ftv1 33.7 -0.0136 0.0278 -0.0400.035 . - 0.036 . . . age.ftv2. 15.9 -0.0340 0.0950 -0.2140.135 . . -0.271 . . smokeTRUE.uiTRUE 2.4 0.0103 0.12090.422 0.652. . . . . nVar3 4 3 1 2 post prob 0.117 0.086 0.083 0.061 0.044 1. how should I write my final logistic model? 2. Which parameter estimation should be used, condEV OR EV? How should I use the two different parameter estimations correctly? Thanks for your precious time! -- Kind Regards, Zhi Jie,Zhang [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] questions on aggregate data
Dear friends, my question is how to aggregate dataset and the inverse manipulation. e.g.My dataset data structure1: x 1 1 2 3 3 data structure2: x freq 1 2 2 1 3 2 Then how to generate dataset2 from dataset1 and generate dataset1 from dataset2? e.g. dataset2 from dataset1 : x<-c(1,1,2,3,3) a<-tab(x) as.data.frame(a) *But i can't do the inverse manipulation:generate dataset1 from dataset2*, anybody can help me on the two different manipulations? Thanks a lot! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help on fitting negative binomial distribution with MLE
Dear friends, Anybody knows how to fit the negative binomial distribution with MLE using R or other software? I can't find the solution, any suggestions or help would be greatly appreciated. -- Kind Regards, Zhi Jie,Zhang [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] set the bahavior that R deal with missing values?
Dear Rusers, The default behavior in R when performing a regression model with missing values is to exclude any case that contains a missing value? How could i set the bahavior that R deal with missing values? e.g.: exclude cases listwise exclude cases pairwise replace with mean Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] set the bahavior that R deal with missing values?
Dear Rusers, The default behavior in R when performing a regression model with missing values is to exclude any case that contains a missing value? How could i set the bahavior that R deal with missing values? e.g.: exclude cases listwise exclude cases pairwise replace with mean Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] which model (GLMs)is the best?
Dear friends, I used R to analyze my data with the models of generalized linear models, and found three models were relatively good, but i can't decide which is the best,how should i do ? *Model1:* glm(formula = snail ~ grass + gheight + humidity + altitude + soiltem + airtem + grass:altitude, *family = Gamma(link = inverse*), data = model, na.action = na.exclude, control = list(epsilon = 1e-04, maxit = 50, trace = T)) (Dispersion parameter for Gamma family taken to be 0.2644025) Null deviance: 63.635 on 161 degrees of freedom Residual deviance: 42.324 on 151 degrees of freedom AIC: 1528.1 *Model2:* glm(formula = snail ~ grass + gheight + humidity + altitude + soiltem + airtem + grass:altitude, *family = quasi(link = inverse, variance = "mu^2")*, data = model, na.action = na.exclude, control = list(epsilon = 1e-04, maxit = 50, trace = F)) (Dispersion parameter for quasi family taken to be 0.2644025) Deviance Residuals: Null deviance: 63.635 on 161 degrees of freedom Residual deviance: 42.324 on 151 degrees of freedom AIC: NA * * *Model3:* glm(formula = snail ~ grass + gheight + humidity + altitude + soiltem + airtem + grass:altitude, *family = quasi(link = log, variance = "mu^3"),*data = model, na.action = na.exclude, control = list(epsilon = 1e-04, maxit = 50, trace = F)) (Dispersion parameter for quasi family taken to be 0.005042872) Deviance Residuals: Null deviance: 1.4113 on 161 degrees of freedom Residual deviance: 1.0080 on 151 degrees of freedom AIC: NA How should i evaluate my models in R? Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to name a variable?
Dear friends, The "s" in the following argument don't have a variable name, how should i give it a name? > s<-data.frame(seq(1,6,by=2)) > s seq.1..6..by...2. 1 1 2 3 3 5 thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] questions on data management
Dear friends, suppose i have two datasets: A and B A: id<-1:6 x<-c(1,2,3,4,5,6) y<-c(2,4,6,8,3,2) xy<-data.frame(id,x,y) B m<-c(1,1,3,3,5,5) n<-c(2,2,6,6,3,3) mn<-data.frame(m,n) Now, i want to perfomr two tasks: 1. get a subset of B,no duplicate values,: C: m n 1 2 3 6 5 3 2.Extract the values in A on the conditions that x=m and y=n the results should be: id x y 1 1 2 3 3 6 5 5 3 Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] who can explain the difference between the R and SAS on the results of GLM
Dear friends, I used R and SAS to analyze my data through generalized linear model, and there is some difference between them. Results from R: glm(formula = snail ~ grass + gheight + humidity + altitude + soiltemr + airtemr, family = Gamma) Deviance Residuals: Min1QMedian3Q Max -1.23873 -0.41123 -0.08703 0.24339 1.21435 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.024e-02 1.655e-02 1.223 0.22320 grasshuanghuacai 1.321e-02 5.053e-03 2.615 0.00982 ** grasshucao1.962e-04 1.971e-03 0.100 0.92083 grassyuhao -1.881e-03 2.041e-03 -0.922 0.35810 gheight -1.275e-04 6.288e-05 -2.027 0.04441 * humidity 6.797e-02 2.278e-02 2.983 0.00332 ** altitudelow -5.090e-03 1.905e-03 -2.671 0.00837 ** soiltemr -8.584e-04 5.165e-04 -1.662 0.09858 *.* #is it show that soiltemr maybe significant at a=0.05??? airtemr 6.547e-05 1.803e-04 0.363 0.71695 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for Gamma family taken to be 0.2745989) Null deviance: 63.635 on 161 degrees of freedom Residual deviance: 43.214 on 153 degrees of freedom AIC: 1527.6 Results From SAS *proc* *genmod* data=a order=data; class grass altitude; model snail = grass gheight humidity altitude soiltemr airtemr / dist=gamma type3; *run*; Analysis Of Parameter Estimates Standard Wald 95% Confidence Chi- Parameter DF Estimate Error Limits Square Pr > ChiSq Intercept 1 0.0202 0.0160-0.0111 0.0516 1.60 0.2052 grass hucao 1 0.0002 0.0019-0.0035 0.0039 0.01 0.9179 grass yuhao 1-0.0019 0.0020-0.0057 0.0020 0.91 0.3397 grass huanghuacai1 0.0132 0.0049 0.0037 0.0228 7.34 0.0068 grass diluo 0 0. 0. 0. 0. . . gheight1-0.0001 0.0001-0.0002-0. 4.41 0.0358 humidity 1 0.0680 0.0220 0.0249 0. 9.55 0.0020 altitudelow1-0.0051 0.0018-0.0087-0.0015 7.66 0.0057 altitudehigh 0 0. 0. 0. 0. . . soiltemr 1-0.0009 0.0005-0.0018 0.0001 2.96 0.0852 airtemr1 0.0001 0.0002-0.0003 0.0004 0.14 0.7067 Scale 1 3.9077 0.4170 3.1702 4.8167 NOTE: The scale parameter was estimated by maximum likelihood. The GENMOD Procedure LR Statistics For Type 3 Analysis Chi- Source DF SquarePr > ChiSq grass 3 17.600.0005 gheight 1 4.260.0390 humidity 1 9.110.0025 altitude 1 7.670.0056 soiltemr 1 2.890.0889 airtemr 1 0.140.7050 Questions: 1.About the variable soiltemr: R could say it maybe significant at 0.05, while SAS don't give this information,why was that in R? 2.Their dispersion parameters are different, although they are estimated automatically,why? 3.From R's Results, i can write my model like this: snail=1.321e-02* grasshuanghuacai+1.962e-04* grasshucao-1.881e-03* grassyuhao-1.275e-04*gheight+6.797e-02*humidity-5.090e-03*altitudelow-8.584e-04*soiltemr is it correct? thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how do we sample in spatial statistics?
Dear friends, -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] random sampling problems?
Dear friends, suppose my dataset is the following data: id<-1:9 x<-c(1,2,3,1,2,3,1,2,3) y<-c(1,1,1,2,2,2,3,3,3) data<-data.frame(id,x,y) id x y 1 1 1 1 2 2 2 1 3 3 3 1 4 4 1 2 5 5 2 2 6 6 3 2 7 7 1 3 8 8 2 3 9 9 3 3 i want to do sampling like this:say the sample size is 3. First: random sampling from x; Next ,random sampling from y ;and combing sampled x and sampled y; Finally, output the samples: id x and y. I think i could call it two-dimension sampling. Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] do i set the correct argument?
Dear friends, In gls() of nlme package, there is some explanation on correlation: gls(model, data, correlation, weights, subset, method, na.action, control, verbose) correlation: an optional 'corStruct' object describing the within-group correlation structure. See the documentation of 'corClasses' for a description of the available 'corStruct' classes. If a grouping variable is to be used, it must be specified in the 'form' argument to the 'corStruct' constructor. Defaults to 'NULL', corresponding to uncorrelated errors. Now i have two categorical variables: grass and altitude, *gls.fit <-gls(log(snail)~grass+altitude+gheight+humidity+soiltemr+airtemr,data=model,correlation=corAR1( form=~grass+altitude))* Is the above argument that i use right? thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] could i change the ouput style on summary?
Dear friends, summary() doesn't give a good ouput style,e.g.: grasssoiltem airtem gheight humidity altitude diluo :38 Min. :15.90 Min. :17.70 Min. : 8.00 Min. : 0.2360 high: 43 huanghuacai:32 1st Qu.:19.32 1st Qu.:22.60 1st Qu.:40.00 1st Qu.: 0.3190 low :119 hucao :46 Median :20.20 Median :25.30 Median :60.00 Median : 0.3399 yuhao :46 Mean :20.52 Mean :26.43 Mean :51.93 Mean : 0.3423 3rd Qu.:21.48 3rd Qu.:29.73 3rd Qu.:70.00 3rd Qu.: 0.3627 Max. :28.60 Max. :42.10 Max. :90.00 Max. : 0.4453 could i get a result like the following: colums are statistical indices and the rows are variables *min 1st Qu. Median Mean 3rd Qu. Max. variance grass* *soiltem * *airtem* which could be copy and used in the papers easily? Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to get the studentized residuals in lm()
Dear friends, In s-plus, lm() generates the the studentized residuals automatically for us, and In R, it seems don't have the results: After i fitted lm(), i use attibutes() to see the objects and didn't find studentized residuals . How to get the the studentized residuals in lm(),have i missed something? thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to recode in my dataset?
Dear Rusers, My question is about "recode variables". First, i'd like to say something about the idea of recoding: My dataset have three variables:type,soiltem and airtem,which means grass type, soil temperature and air temperature. As we all known, the change of air temperature is greater than soil temperature,so the values in those two different temperaturemay represent different range. My recoding is to recode soiltem with 0.2 intervals, and airtem with 0.5 intervals, that is: In soiltem:0~0.2<-0.1, 0.2~0.4<-0.3, 0.4`0.6<-0.5,...etc; In airtem:0~0.5<-0.25, 0.5~1<-0.75, 1`1.5<-1.25,...etc; My example like this: type<-c(1, 1, 2, 3,4,1,1,4,3,2) soiltem<-c(19.2,18.6,19.5,19.8,19.6,20.6,19.1,18.7,22.4,21.6) airtem<-c(19.9,20.5,21.6,25.6,22.6,21.3,23.7,21.5,24.7,24.4) mydata<-data.frame(type,soiltem,airtem) #copy the above four arguments to generate the dataset mydata type soiltem airtem 1 119.2 19.9 2 118.6 20.5 3 219.5 21.6 4 319.8 25.6 5 419.6 22.6 6 120.6 21.3 7 119.1 23.7 8 418.7 21.5 9 322.4 24.7 10221.6 24.4 Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] replace values?
Dear friends, i have a dataset like this: x y z 1 2 3 2 3 1 3 2 1 1 1 3 2 1 2 3 2 3 2 1 1 I want to replace x with the following values:1<-a,2<-b,3<-c,4<-d; replace y with the following values:1<-b,2<-a,3<-c,4<-d; replace z with the following values:1<-d,2<-c,3<-b,4<-a; Finally,select two subsets: 1. if x='a'; 2.x='a' and y='a'; thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] general linear model and generalized linear model
Dear friends, I searched the R site and found a lot of results on general linear model and generalized linear model , and i was confused by them. Here, I only want to get some concise answers on the following questions and i'll study it by your hints: 1. Which function(package) could be used to fit the general linear model ? 2. Which function(package) could be used to fit the generalized linear model ? 3. How to tell them which variables in my dataset are categorical variables that will be used as dummy variables? Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] A question related with resale()
Dearfriends, A question related with resale(). I have a dataset *a* with three variables *x,y,id* I want to do two different things: 1. rescale the combination of x and y into the new range --unit square(0,1),that is, keep the shape of original plot; 2.rescale x and y into the new range (0,1) respectively,change the shape of original plot ; e.g. the orignial dataset id<-c(1,2,3,4,5,6,7,8,9,10) x<-rnorm(10) y<-rnorm(10) a<-data.frame(id=id,x=x,y=y) Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to finish my task?
Dearfriends, A question related with resale(). I have a dataset *a* with three variables *x,y,id* I want to do two different things: 1. rescale the combination of x and y into the new range (0,1),that is, keep the shape of original plot; 2.rescale x and y into the new range (0,1) respectively,change the shape of original plot ; e.g. id<-c(1,2,3,4,5,6,7,8,9,10) x<-rnorm(10) y<-rnorm(10) a<-data.frame(id=id,x=x,y=y) Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] rescale the data into unit square?
Dear Rusers, Recently, i saw the sentence "rescale the data into unit square" for several times. Could anybody tell me what it means,and give an example? Thanks very much! -- Kind Regards, Zhi Jie,Zhang , [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to put the results of loop into a dataframe
Dear friends, suppose i want to do the following caulation for 100 times, how to put the results of x , y and z into the same dataframe/dataset? x<-runif(1) y<-x+1 z<-x+y thanks in advance! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to put the results of loop into a dataframe
Dear friends, suppose i want to do the following caulation for 100 times, how to put the results of x , y and z into the same dataframe/dataset? x<-runif(1) y<-x+1 z<-x+y thanks in advance! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to analyze the following data?--anxious for the result
Dear friends, I have a dataset: response var--y, class var-group, and the third variable-x. I want to test whether there is statistical significance bewteen group for y with the controlled x. First, i want to use analysis of covariance in SAS, but i found that y isn't noramal and can't become normal through transformation. Under that condition, what should i do using R / SAS? Any suggestions are great appreciate! -- Kind Regards,Zhi Jie,Zhang ,PHDDepartment of EpidemiologySchool of Public HealthFudan UniversityTel:86-21-54237149 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to do multiple comparison in the nonparametric statistical analysis?
Dear Rusers, As we all know , there are many methods to do multiple comparison in the parametric statistical analysis, But i can't find some in nonparametric statistical analysis. Could anybody give some suggestions? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] a question on subset a dataset
Dear R-users, I generate a dataset "d", and want to get a subset from it. ** *z<-rnorm(9) coords<-cbind(x=c(1,1,1,2,2,2,3,3,3),y=c(1,2,3,1,2,3,1,2,3)) d<-SpatialPointsDataFrame(coords, data.frame (z=z[1:9]))* The result*/dataset* is coordinates z 1 (1, 1) 1.41173570 2 (1, 2) 0.18546503 3 (1, 3) -0.04369144 4 (2, 1) -0.21591338 5 (2, 2) 1.46377535 6 (2, 3) 0.2294 7 (3, 1) 0.10762363 8 (3, 2) -1.37810256 9 (3, 3) - 0.96818288 Now I want oto get a subset with x(rows) and y(columns) being odd numbers , that is , i want the subset like the following: coordinates z (1, 1) 1.41173570 (1, 3)-0.04369144 (3, 1) 0.10762363 (3, 3)-0.96818288 I think that the steps maybe: 1.decompose coords into the original x and y; 2.select the odd numbers of x and y; 3.combine the selected x and y into coordinates, including the corresponding z-values. This is the subset. Hope someone can solve it. I failed to get the subset. -- Kind Regards,Zhi Jie,Zhang ,PHDDepartment of EpidemiologySchool of Public HealthFudan UniversityTel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] subset a matrix
Dear friends, I have a (20*30) matrix,and want to get a subset of it like the following: The original matrix: rows:1,2,3,20; columns:1,2,3,30 I want to get my subset of The original matrix and delete others: rows:1,3,5,7,...19; columns:1,3,5.29 -- Kind Regards,Zhi Jie,Zhang ,PHDDepartment of EpidemiologySchool of Public HealthFudan UniversityTel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Is there any method to compare Moran's I between different populations?
Is there any method to compare Moran's I between different populations? As we know, in classical statistics ,there are ttest,Anova,...which can be used to compare means in different populations,so we can make a decision whether their means are different or not. But spatial statistics seems not to have methods to compare Moran's I between different populations. Is it true? Another question is that spatial statistics don't pay enough attention to descriptive spatial statistical index, but it maybe important in my opinion. So have anybody seen some good materials on descriptive spatial statistical index,such as mean center ,median center..? thanks in advance! -- Kind Regards, [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] who can tell me the reason why it is different on calculating Moran's I using ARCGIS, Geoda and R?
The attachment is my dataset: 1.ccc.shp (the original data) 2.ccc.gwt, which is computed by Geoda; Introduction to the variables in my data: ID: key variable; N_LATITUDE: latitude measured by GPS; E_LONGITUD: longitude measured by GPS; LIVES: attribute data I get the different result of Moran's between ARCGIS and Geoda, R, why? ARCGIS:spatial statistics tools:spatial autocorrelation(Moran's I)=0.0343 GeoDa:Moran's I=0.1539 R:Moran I statistic =0.153905049 The key arguments in R that i use: ccc<-read.gwt2nb("ccc.GWT",region.id=ID) ccc2<-nb2listw(ccc, glist=NULL, style="W", zero.policy=TRUE) moran.test(LIVES,ccc2,alternative="two.sided") what is the problem? I'm very confused by it? Thanks very very much! -- Kind Regards,Zhi Jie,Zhang ,Department of EpidemiologySchool of Public HealthFudan UniversityTel:86-21-54237149 0 264 ccc ID 456 457 0.000161449683 456 471 0.000181372545 456 470 0.000223134489 456 472 0.000252446034 456 455 0.000309741828 439 4382.23606797e-006 439 454 0.000201933157 439 455 0.000221995495 439 453 0.000287360401 439 452 0.000319169234 470 469 0.000162689889 470 456 0.000223134489 470 454 0.000235031913 470 455 0.000236400085 470 484 0.000249327094 501 4869.04267659e-005 501 500 0.000170484603 501 516 0.000182570534 501 515 0.000191415778 501 531 0.000231767124 468 497 0.000136528385 468 482 0.000162692962 468 469 0.000172168522 468 483 0.0001753083 468 453 0.000191637679 495 4666.30713881e-005 495 494 0.00015158496 495 481 0.000175251248 495 451 0.000194550765 495 480 0.000195473783 637 652 0.000149345238 637 651 0.000155415572 637 636 0.000177406313 637 666 0.000196206524 637 622 0.000204560504 621 6367.88733161e-005 621 651 0.000137767921 621 622 0.00016464811 621 607 0.000207542767 621 635 0.000221165097 431 446 0.000143544418 431 430 0.000167170572 431 461 0.000349967141 431 443 0.000389974358 431 447 0.000396295344 430 431 0.000167170572 430 443 0.000278887074 430 446 0.000297847276 430 428 0.000305360443 430 458 0.000419239788 556 585 9.5336247e-005 556 570 0.000130598622 556 555 0.000186938493 556 557 0.00020188363 556 600 0.000234002137 443 428 0.000164514437 443 458 0.000171405951 443 430 0.000278887074 443 473 0.000385498379 443 431 0.000389974358 648 6637.16937933e-005 648 662 0.000172191754 648 633 0.000173326282 648 664 0.000198338095 648 649 0.000199138143 600 615 0.000159806133 600 585 0.00016273291 600 571 0.000165024241 600 586 0.000215406592 600 584 0.000217110571 711 697 0.000185558616 711 712 0.000196290601 711 710 0.000241049787 711 726 0.000257194479 711 696 0.000274963634 458 443 0.000171405951 458 473 0.000216760236 458 428 0.000317056777 458 488 0.000399891235 458 430 0.000419239788 615 5869.07854614e-005 615 600 0.000159806133 615 601 0.000164103626 615 630 0.000184200977 615 571 0.000189264365 473 488 0.000188854441 473 458 0.000216760236 473 443 0.000385498379 473 503 0.000385861374 473 428 0.000533256036 630 6455.65685424e-006 630 6605.65685424e-006 630 6019.33809402e-005 630 6169.73498844e-005 630 586 0.000165710591 709 7072.69072481e-005 709 708 0.000131700418 709 710 0.00018140011 709 722 0.000214140141 709 694 0.000228536649 609 594 0.000213122031 609 624 0.000216279911 609 608 0.000242843571 609 593 0.000313639921 609 623 0.000316172421 703 702 0.000154434452 703 688 0.000157410292 703 689 0.000167693172 703 687 0.00021099 703 717 0.000258156929 608 593 0.000198436388 608 623 0.000213845739 608 594 0.000237255137 608 609 0.000242843571 608 624 0.000311081983 653 668 0.000199218473 653 654 0.000240276924 653 669 0.000270440382 653 683 0.000315901883 653 638 0.000335715653 683 6984.10487515e-005 683 668 0.000133003759 683 669 0.000158492902 683 684 0.000212602916 683 653 0.000315901883 438 4392.23606797e-006 438 454 0.000204166599 438 455 0.000223895065 438 453 0.00022329 438 452 0.00031902351 515 530 0.000158672619 515 516 0.000171592541 515 531 0.000185224188 515 501 0.000191415778 515 514 0.000230054341 514 529 0.000124016128 514 498 0.000157442053 514 513 0.000170496334 514 500 0.000203194488 514 544 0.000209823736 530 5457.73886297e-005 530 515 0.000158672619 530 546 0.000179627392 530 531 0.000182386951 530 516 0.000211085291 576 591 0.000112698713 576 561 0.000132280006 576 547 0.000177485211 576 575 0.000183152942 576 560 0.000184556224 479 4808.74642784e-005 479 451 0.000200643963 479 465 0.00020529491 479 495 0.000
[R] data management on R
Dear friends, i have two dataset: A and B A: x y 1 2 3 4 B: m n 1 2 7 8 How to generate datasetC: C: x n 1 2 3 8 i know sas can do it easily, what about R? -- Kind Regards, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] still unclear about the parameters of Moran's I
I have read the introductions on Moran of SPDEP package, but still unclear about the parameters of Moran's I, and can't calculate the Moran's I. For example,I have a dataset like the following(only an example): longitude latitudex 110.23 32.53 10 109.52 33.2120 I want to use the moran(x, listw, n, S0, zero.policy=FALSE, NAOK=FALSE),and i can't make clear the meaning of the parameters listw and S0 because of my poor understanding on R, could anybody give me some programs to show how to calculate Moran's I? thanks in advance! -- Kind Regards __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to join "specific Special Interest Group (=: SIG) mailing lists"
there are several specific Special Interest Group (=: SIG) mailing lists,and i'm interested in the"R-sig-Geo :R Special Interest Group on using Geographical data and Mapping ",but can't find how to join it, could anybody tell me how to do that? thank u very much! -- Kind Regards,Zhi Jie,Zhang ,PHDDepartment of EpidemiologySchool of Public HealthFudan UniversityTel:86-21-54237149 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] help on moran's I index of point pattern, not areal pattern
hi,friends, we all know that moran's I index and Geary'C index can be used to test spatial autocorrelation in both the area data and point data, but i only can find something on how to calculate on the data of area, and can't find the methods to perform it on the point data, could anybody give me some information, thanks in advance! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology, School of Public Health, Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html