[R] regression by group summary error

arun smartpink111 at yahoo.com
Wed Nov 20 14:47:55 CET 2013


Hi Catalin,

I tried with a subset of the variables.  Infact, there is an option in lmList() to subset

biN <- bi[,c(1,3,22,34)]
str(biN)
'data.frame':    66 obs. of  4 variables:
 $ Exp          : chr  "B" "B" "B" "B" ...
 $ Clona        : Factor w/ 5 levels "A4A","AF2","Max4",..: 3 3 3 3 3 3 3 3 3 3 ...
 $ CR2V.cm.     : num  20.4 19.6 24 22.2 27.6 24.2 19.4 22.2 21.5 28.2 ...
 $ masa.uscat.tr: num  6.2 3.88 7.82 5.65 10.2 ...


 by(biN,biN$Exp, function(x) summary(lmList(masa.uscat.tr~CR2V.cm.|Clona,data=x,na.action=na.omit)))
biN$Exp: B
Call:
  Model: masa.uscat.tr ~ CR2V.cm. | Clona 
   Data: x 

Coefficients:
   (Intercept) 
    Estimate   Std. Error      t value     Pr(>|t|) 
-8.252204377  1.668647582 -4.945444721  0.001127319 
   CR2V.cm. 
    Estimate   Std. Error      t value     Pr(>|t|) 
6.674136e-01 7.218748e-02 9.245559e+00 1.519752e-05 

Residual standard error: 0.6671037 on 8 degrees of freedom

------------------------------------------------------------ 
biN$Exp: C
Call:
  Model: masa.uscat.tr ~ CR2V.cm. | Clona 
   Data: x 

Coefficients:
   (Intercept) 
           Estimate Std. Error   t value   Pr(>|t|)
A4A       -6.941742   6.698275 -1.036348 0.30545738
AF2      -10.368170   4.669365 -2.220467 0.03135312
Max4      -6.766456   2.925135 -2.313211 0.02523457
Monviso    9.493789   3.779740  2.511757 0.01558630
Pannonia  -8.044174   3.617619 -2.223610 0.03112594
   CR2V.cm. 
           Estimate Std. Error   t value     Pr(>|t|)
A4A      0.62752742  0.2513938 2.4961928 1.619954e-02
AF2      0.72802937  0.1609617 4.5229977 4.270833e-05
Max4     0.63517380  0.1377759 4.6101954 3.209599e-05
Monviso  0.04123701  0.1366451 0.3017818 7.641786e-01
Pannonia 0.74293255  0.1187515 6.2561931 1.194664e-07

Residual standard error: 1.473519 on 46 degrees of freedom




A.K.






On Wednesday, November 20, 2013 5:53 AM, catalin roibu <catalinroibu at gmail.com> wrote:

Hello!
I have a problem with R. I want to apply a linear model for data composed by two groups (Exp and Clona). i try this code:
by(bi,bi$Exp, function(x) lmList(masa.uscat.tr~CR2V.cm.|Clona,data=x,na.action=na.omit))

But I want to view to summary for each Exp and i try this code:
by(bi,bi$Exp, function(x) summary(lmList(masa.uscat.tr~CR2V.cm.|Clona,data=x,na.action=na.omit)))

And I have this error:
Error in `[<-`(`*tmp*`, use, use, ii, value = lst[[ii]]) : 
  subscript out of bounds

Please help me to solve this problem!

Thank you very much!

 My data is:

ExpPlotClonaProvmasa uscat trmasa usc. Rammasa usc total
B36Max4 PPuieti6.1998484852.6393258438.839174328
B36Max4 PPuieti3.878751.47985.35855
B36Max4 PPuieti7.8227027033.3285207111.15122341
B36Max4 PPuieti5.6453846151.9952380957.640622711
B36Max4 PPuieti10.23.51486486513.71486486
B36Max4 PPuieti8.8155454553.3562790712.17182452
B36Max4 PPuieti5.0333333331.6071428576.64047619
B36Max4 PPuieti6.6934883722.6302083339.323696705
B36Max4 PPuieti6.0210126581.602935787.623948438
B36Max4 PPuieti10.205825243.76831460713.97413985
B33Max4Butasi5.8994174761.7453947377.644812213
B33Max4Butasi3.2614285711.3357352944.597163866
B33Max4Butasi3.3595081971.4566412214.816149418
B33Max4Butasi5.0363636362.0977931037.13415674
B33Max4Butasi3.1221621621.6120125794.734174741
B33Max4Butasi5.0424742273.2469164278.289390653
B33Max4Butasi5.0582558142.7242990657.782554879
B33Max4Butasi4.9778181821.7135042746.691322455
B33Max4Butasi3.1952941181.2434117654.438705882
B33Max4Butasi1.8318181821.0090909092.840909091
B30AF2Butasi6.981951221.7648.74595122
B30AF2Butasi5.8583333331.6866233777.54495671
B30AF2Butasi10.6253.0413.665
C39AF6Sade10.271252.28319327712.55444328
C39AF6Sade9.4734883721.90941441411.38290279
C39AF6Sade10.4825212.4825
C39AF6Sade11.615795452.43113636414.04693182
C39AF6Sade8.1850746271.8093333339.99440796
C39AF6Sade11.045106382.2367295613.28183594
C39AF6Sade9.0666666672.47378571411.54045238
C39AF6Sade10.127876113.09763157913.22550769
C39AF6Sade9.1712903231.82122641510.99251674
C39AF6Sade12.18468752.26259036114.44727786
C42PannoniaSade9.2752.48217391311.75717391
C42PannoniaSade7.211.778.98
C42PannoniaSade11.369393943.11178082214.48117476
C42PannoniaSade7.852968751.9434751779.796443927
C42PannoniaSade8.252.5404761910.79047619
C42PannoniaSade8.6692771082.18707142910.85634854
C42PannoniaSade8.5108860762.0534410.56432608
C42PannoniaSade9.3622222225.52553191514.88775414
C42PannoniaSade11.084819282.57319327713.65801255
C42PannoniaSade10.174626873.00322580613.17785267
C45MonvisoSade12.996938783.21608391616.21302269
C45MonvisoSade11.114565221.88571428613.0002795
C45MonvisoSade8.1293333331.5326666679.662
C45MonvisoSade9.9430434782.3830088512.32605233
C45MonvisoSade11.98058143.08092391315.06150531
C45MonvisoSade10.313766232.21052631612.52429255
C45MonvisoSade9.9475862071.86083333311.80841954
C45MonvisoSade12.242615382.16685714314.40947253
C45MonvisoSade13.566506022.41437125715.98087728
C45MonvisoSade10.875742572.92234042613.798083
C48AF2Sade9.3345454552.20182291711.53636837
C48AF2Sade9.7476404492.81178082212.55942127
C48AF2Sade14.295412844.50688524618.80229809
C48AF2Sade10.264516133.01432258113.27883871
C48AF2Sade13.309242423.96066176517.26990419
C48AF2Sade13.232284265.0054687518.23775301
C48AF2Sade14.82770274.45044776119.27815046
C48AF2Sade15.236695287.55932203422.79601731
C48AF2Sade13.271985823.75825242717.03023824
C48AF2Sade13.713644445.69044444419.40408889
C51Max4Sade8.8608849565.61358695714.47447191
C51Max4Sade13.291532855.65306122418.94459407
C51Max4Sade9.6098507463.38571428612.99556503


-- 

---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone       +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
                       +4 0766 71 76 58
FAX:                          +4 0230 52 16 64
silvic.usv.ro



More information about the R-help mailing list