[R] for loop using index values

2014-05-14 Thread David Gwenzi
Hi all

I have point data along a transect and I want to divide the transect into
small blocks of 10m length each. I have named the blocks as a list i.e
subset[[i]]. Now the issue is I want to process only those blocks that have
at least 100 data points and keep the original index values of those
subsets. How do I set the for loop. I have tried the following but it is
still processing everything

select-which(nrow(subset[[i]])=100
for (i in c(select)){
..
}
 Thank you in advance,

David Gwenzi
Graduate Degree Program in Ecology
Natural Resources Ecology Lab
Colorado State University

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Fwd: Intepreting lm() results with factor

2013-12-02 Thread David Gwenzi
Dear all

I have observations done in 4 different classes and the between classes
*variance* is too high that I decided to run a model without pooling the
*variance*. I used the following code first :
   model-lm(y~x+factor(class))
and got the following output:
Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept) 52.41405   17.38161   3.015  0.00658 **
x0.276790.07387   3.747  0.00119 **
factor(class)2  92.68083   32.26645   2.872  0.00912 **
factor(class)3 197.82029   33.24916   5.950 6.63e-06 ***
factor(class)4 105.61266   55.18373   1.914  0.06937 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 43.07 on 21 degrees of freedom
Multiple R-squared:  0.9206,Adjusted R-squared:  0.9055
F-statistic: 60.91 on 4 and 21 DF,  p-value: 2.976e-11

My understanding of this output is that class 1 is used as a baseline
(constant) and each other class's p values means for example the dependent
value in class 2 is significantly different from that of class 1.
Now I ran the model again, but without using a constant i.e
model-lm(y~x+factor(class)-1)
and got the following output:
Coefficients:
Estimate Std. Error t value Pr(|t|)
x0.276790.07387   3.747  0.00119 **
factor(class)1  52.41405   17.38161   3.015  0.00658 **
factor(class)2 145.09488   39.42651   3.680  0.00139 **
factor(class)3 250.23434   40.61189   6.162 4.11e-06 ***
factor(class)4 158.02672   64.09549   2.465  0.02238 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 43.07 on 21 degrees of freedom
Multiple R-squared:  0.9801,Adjusted R-squared:  0.9754
F-statistic: 207.1 on 5 and 21 DF,  p-value:  2.2e-16

Can somebody please tell me how to interpret this one now? what do the
classes' P values mean ? Do they merely show if they significantly
contribute to the model or whether they are significantly different from
the overall mean or not? Does it mean if one class had a p value  0.05 it
would mean the observations from that class are not significantly
contributing to the model?

Thanks in advance

David

[[alternative HTML version deleted]]

__
R-help@r-project.org 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 nls results different from those of Excel ??

2013-02-18 Thread David Gwenzi
Hi all

I have a set of data whose scatter plot shows a very nice power
relationship. My problem is when I fit a Power Trend Line in an Excel
spreadsheet, I get the model y= 44.23x^2.06 with an R square value of 0.72.
Now, if I input the same data into R and use
model -nls(y~ a*x^b , trace=TRUE, data= my_data, start = c(a=40, b=2)) I
get a solution with a = 246.29 and b = 1.51. I have tried several starting
values and this what I always get. I was expecting to get a value of a
close to 44 and that of b close to 2. Why are these values of a and b
so different from those Excel gave me. Also the R square value for the nls
model is as low as 0.41. What have I done wrong here? Please help. Thanks
in advance

David

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.