[R] 95% confidence intercal with glm

2010-09-28 Thread zozio32

Hi

I had to use a glm instead of my basic lm on some data due to unconstant
variance.

now, when I plot the model over the data, how can I easily get the 95%
confidence interval that sormally coming from:
  
   yv - predict(modelVar,list(aveLength=xv),int=c)
   matlines(xv,yv,lty=c(1,2,2))

There is no interval argument to pass to the predict function when using a
glm, so I was wondering if I had to use an other function

thanks 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/95-confidence-intercal-with-glm-tp2716906p2716906.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] help interpreting a model summary

2010-09-21 Thread zozio32


David Winsemius wrote:
 
 
 On Sep 19, 2010, at 5:59 PM, zozio32 wrote:
 

 Thanks for you're long answer.
 I have to say, I am not fully sure of what you're meaning  
 everywhere. As I
 said, I am merely following a recipe book, and when things depart  
 from it I
 am a bit lost.

 I'll try to answer to each of your paragraphs:
 3:  I was not wanting to include 3-way interactions, but that's the  
 only
 way I found to include a 2 way interaction in my piecewise linear  
 model.
 
 Yes. That makes sense to me.
 
 I could obviously include only angleNoise*reflection, but I thought  
 that was
 not very consistent with the fact that reflection variable was split  
 in 2.
 I could may be define the point of separation, and then create 2  
 separate
 models in the form lm(weightedDiff ~ angleNoise*reflection).
 
 Yes, I see that you did, and that may be helpful in understanding the  
 estimates. The question I would ask you is why you are putting a  
 breakpoint in a physical model. Unless there is a phase change or some  
 discontinuity in effects at that point, I think the breakpoint looks  
 artificial. Is refelction somehow physically connected with the  
 breakpoint? Some sort of acoustic timing phenomenom? Or reflected wave  
 effect in a hydraulic model?
 
 
 I am generating waves in a wave tank and I have some of it bouncing back
from the tank wall to mess up my measures, and i want to quantify this
effect. weightedDiff is a measure of the difference between the target
spectra and what I am measuring.   For that I have generated virtual wave
elevation with different level of reflection and I am analysing the results
of my waves measurement method.
Basically, I can observe a strong curvature in my data weightedDiff as a
function of reflection. Now, I can try to model this curvature by a
square term, a linear piece wise linear model or may be a log model in the
form y = a*log(x)+b.I don't like the square model as it will not go to
+inf with reflection - +inf.
So I've tried the second option with what I thought was not too bad results
...
I think I'll investigate the log option now. i have to say that speaking to
someone definitely clears up my mind on this. And R is not the cup of tea of
people in my department.
I am not really thinking that there is a breaking point, but that the
influence of the angleNoise perturbations (level of uncertainty in the
direction of propagation of my waves) is negligible when the reflection get
too high. If I could identify this point, or a king of limit between 2 zones
( one with reflection low enough that angleNoise as to be taken into
account, one with reflection so high that angleNoise do not matter any
more) that will be helpful.




 
 I merely
 thought that my formulation was a way to combine them together.
 Basically, i am expecting both parameters to degrade my signal, but  
 I'll not
 be surprised if passed a certain level of reflection, having noise  
 or not in
 my angles is not really relevant, hence the interaction parameter. The
 piecewise linear model is a way to take into account the curvature  
 in the
 data that I can observe on a straight scatter plot.

 1:  Thanks for the first part, i think I can make sens of it. ;)
 I guess I can ignore this parameter in that case.  By the way, which  
 type of
 Anova you refering to: creating a factor with high and low level  
 of
 interation, and fitting the interation between angleNoise and this new
 factor?
 
 If you took a model with all of the data and fit first a model without  
 the break point and one with the breakpoint and then looked at the  
 output of anova(model1) and annova(model2) the difference in deviance  
 across the two models is distributed (asymptotically anyway) as a chi- 
 square statistic with the difference in number of degrees of freedom.  
 That's a much better basis for deciding whether the addition of the  
 term is statistically significant.
 
yeah, I did that and there is definitely no match for the linear model
without the break or square term, or anything. I just need to model this
curvature somehow to get a decent model here.  As I am using virtual wave
elevation, I have over 600 observations point, so the anova test results are
not ambiguous at all.



 2: first, i was mislead by the meaning of this factor. i only  
 encounter the
 version were it's TRUE, not FALSE which is the difference.
 I think I also use important in a wrong way. I should have used
 significant instead.
 
 You had specified a model that that terms with both (reflection =  
 Break[xMin]) and (reflection  Break[xMin]) and the lm program  threw  
 away all the levels with reflection = Break[xMin]. If you had only  
 specified the the model with only reflection = Break[xMin] you would  
 have gotten an identical model as far as predictions were concerned,  
 but the signs would have been reversed for any of the levels with the  
 inequality term in them.
 
 After, i have to admit that I am lost  when

[R] help interpreting a model summary

2010-09-19 Thread zozio32

Hello, I am all new here.
Thanks for the job done, R really helped me in my thesis lately. However, I
am kind of new in statistics, coming from mecanical engineering, and I
mostly teached myself with The R Book, so I may do silly things some time.
PLease tell me if you think so.

Anyway, I've just build up a piecewise linear model to fit some data,
including some interaction and i am not sure of how to interpret the
summary:.
here it is:


Call:
lm(formula = weightedDiff ~ angleNoise + (reflection  Break[xMin]) * 
reflection + (reflection = Break[xMin]) * reflection +
angleNoise:(reflection  
Break[xMin]) * reflection + angleNoise:(reflection = Break[xMin]) *
reflection)

Residuals:
   Min 1Q Median 3QMax 
-1.073e-03 -1.749e-04 -5.913e-06  1.650e-04  1.311e-03 

Coefficients: (4 not defined because of singularities)
  Estimate Std. Error
(Intercept)  0.0134798  0.0001086
angleNoise   0.0004658  0.0002245
reflection  Break[xMin]TRUE-0.0028766  0.0001236
reflection   0.0316122  0.0014741
reflection = Break[xMin]TRUE   NA NA
reflection  Break[xMin]TRUE:reflection  0.0683631  0.0027668
reflection:reflection = Break[xMin]TRUENA NA
angleNoise:reflection  Break[xMin]TRUE  0.0011158  0.0002548
angleNoise:reflection = Break[xMin]TRUENA NA
angleNoise:reflection  Break[xMin]FALSE:reflection -0.0055751  0.0030620
angleNoise:reflection  Break[xMin]TRUE:reflection  -0.0343745  0.0049164
angleNoise:reflection:reflection = Break[xMin]TRUE NA NA

  
t value   Pr(|t|)
(Intercept) 
 
124.079   2e-16   ***
angleNoise  
 
2.075   0.0384*  
reflection  Break[xMin]TRUE   
-23.2652e-16  ***
reflection  
  
21.445 2e-16  ***
reflection = Break[xMin]TRUE
NA NA
reflection  Break[xMin]TRUE:reflection 
24.7082e-16***
reflection:reflection = Break[xMin]TRUE   NA   
  
NA
angleNoise:reflection  Break[xMin]TRUE 4.379 
1.41e-05  ***
angleNoise:reflection = Break[xMin]TRUE   NA   
  
NA
angleNoise:reflection  Break[xMin]FALSE:reflection  -1.821 
0.0692.  
angleNoise:reflection  Break[xMin]TRUE:reflection-6.992   
7.35e-12  ***
angleNoise:reflection:reflection = Break[xMin]TRUE  NA
NA
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.0002885 on 592 degrees of freedom
Multiple R-squared: 0.9666, Adjusted R-squared: 0.9662 
F-statistic:  2450 on 7 and 592 DF,  p-value:  2.2e-16 


Basically, I am really not sure of the meaning of this parameter:
 angleNoise:reflection  Break[xMin]FALSE:reflection

Overall, my interpretation is that reflection is important , angle Noise
also but specially when reflection is below the breaking point. Is that
correct?

well, sorry for the first long post

thanks in advance

-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-interpreting-a-model-summary-tp2546161p2546161.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] help interpreting a model summary

2010-09-19 Thread zozio32

Thanks for you're long answer.
I have to say, I am not fully sure of what you're meaning everywhere. As I
said, I am merely following a recipe book, and when things depart from it I
am a bit lost.

I'll try to answer to each of your paragraphs:
 3:  I was not wanting to include 3-way interactions, but that's the only
way I found to include a 2 way interaction in my piecewise linear model.   
I could obviously include only angleNoise*reflection, but I thought that was
not very consistent with the fact that reflection variable was split in 2. 
I could may be define the point of separation, and then create 2 separate
models in the form lm(weightedDiff ~ angleNoise*reflection). I merely
thought that my formulation was a way to combine them together.
Basically, i am expecting both parameters to degrade my signal, but I'll not
be surprised if passed a certain level of reflection, having noise or not in
my angles is not really relevant, hence the interaction parameter. The
piecewise linear model is a way to take into account the curvature in the
data that I can observe on a straight scatter plot.

1:  Thanks for the first part, i think I can make sens of it. ;)
I guess I can ignore this parameter in that case.  By the way, which type of
Anova you refering to: creating a factor with high and low level of
interation, and fitting the interation between angleNoise and this new
factor?

2: first, i was mislead by the meaning of this factor. i only encounter the
version were it's TRUE, not FALSE which is the difference.
I think I also use important in a wrong way. I should have used
significant instead.
After, i have to admit that I am lost  when you're talking about models with
reversed inequality...

4. Not much to say here, i knew they were pointless but the results from my
formulation of the model. I don't thnik there is a need to removed them no?


-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-interpreting-a-model-summary-tp2546161p2546292.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] help interpreting a model summary

2010-09-19 Thread zozio32

Actually, rereading trough my post, I think I understood a bit better now.
I have now fit a much simpler to each part of the data, and things looks a
bit easier to understand.

for the part were reflection  break[xmin], i now have:

Call:
lm(formula = weightedDiff ~ angleNoise * reflection, data = data1)

Residuals:
   Min 1Q Median 3QMax 
-1.081e-03 -2.296e-04  1.335e-05  2.010e-04  1.287e-03 

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)1.057e-02  7.536e-05 140.273   2e-16 ***
angleNoise 1.648e-03  1.542e-04  10.684   2e-16 ***
reflection 1.021e-01  3.155e-03  32.361   2e-16 ***
angleNoise:reflection -3.877e-02  6.679e-03  -5.804  2.1e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.0003556 on 233 degrees of freedom
Multiple R-squared: 0.8971, Adjusted R-squared: 0.8957 
F-statistic: 676.9 on 3 and 233 DF,  p-value:  2.2e-16 


and for the other I have:

Call:
lm(formula = weightedDiff ~ angleNoise * reflection, data = data2)

Residuals:
   Min 1Q Median 3QMax 
-6.252e-04 -1.391e-04 -1.086e-05  1.365e-04  7.281e-04 

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)1.342e-02  8.197e-05 163.715   2e-16 ***
angleNoise 5.577e-04  1.696e-04   3.289  0.00110 ** 
reflection 3.236e-02  1.127e-03  28.722   2e-16 ***
angleNoise:reflection -6.719e-03  2.340e-03  -2.871  0.00433 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.0002341 on 359 degrees of freedom
Multiple R-squared: 0.8269, Adjusted R-squared: 0.8254 
F-statistic: 571.5 on 3 and 359 DF,  p-value:  2.2e-16 


i hope i can now safely conclude that both parameters are significant, and
that their respective slope decreases when reflection is  Break[xMin]
I also assume that the negative sign on both interaction term can be
interpret as angleNoise influence decreaes as reflection increases.
Is that a more sensible interpretation of my data?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-interpreting-a-model-summary-tp2546161p2546303.html
Sent from the R help mailing list archive at Nabble.com.

__
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.