[R] The contrary of command %in%

2006-04-20 Thread Ghislain Vieilledent
Dear r-list,

I've got a data base:
 HData[1:10,]
   NumTree   Site Species Date Age DBHH IdentTree
11 Queige  Spruce 2002 184  49 33.5  Queige 1
22 Queige Fir 2002  NA   5  4.6  Queige 2
33 Queige Fir 2002  25   8  6.6  Queige 3
44 Queige  Spruce 2002 198  47 32.5  Queige 4
55 Queige Fir 2002 200  59 35.3  Queige 5
66 Queige  Spruce 2002  80  16  9.4  Queige 6
77 Queige Fir 2002  NA   5  4.2  Queige 7
88 Queige Fir 2002 200  44 32.5  Queige 8
99 Queige Fir 2002  NA   5  3.4  Queige 9
10  10 Queige  Spruce 2002 167  48 32.8 Queige 10
...

I want to remove particular points determined by
 HDataPartP-HData[H1.30,]
and
 HDataPartP2-HData[H8DBH20,]

That's why I want to use subset in a close form to:
HData2-subset(HData,HData$H1.30HData$IdentTree
not%in%HDataPartP2$IdentTree)

How should I do that ?
Is there any R-syntax saying not element of that object ?

Thanks for your help.

Ghislain.

--
Ghislain Vieilledent
06 24 62 65 07

[[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] Question on glm for Poisson distribution.

2005-07-27 Thread Ghislain Vieilledent
Good afternoon,

I REALLY try to answer to my question as an autonomous student searching in 
the huge pile of papers on my desk and on the Internet but I can't find out 
the solution. 
Would you mind giving me some help? Please.

#

I'm trying to use glm with factors:

 Pyr.1.glm-glm(Pyrale~Trait,DataRav,family=poisson)

If I have correctly payed attention to my cyber professor explanations I 
have, for the variable Pyrale which I suppose Poisson-distributed, the 
following mathematical expression:

P(Pyrale=k)=exp(-m).[(m^k)/k!]
with log(m)=Intercept+Trait(i) (link function is log for Poisson 
distribution)

Then I test the significativity of Trait:

 anova(Pyr.1.glm,test=Chisq)
Analysis of Deviance Table

Model: poisson, link: log

Response: Pyrale

Terms added sequentially (first to last)


Df Deviance Resid. Df Resid. Dev P(|Chi|)
NULL 19 49.813 
Trait 3 31.281 16 18.532 7.419e-07

Which means that variable Trait is significant for determining the value of 
P(Pyrale=k).

I tried to order the effects of the modalities of my variable Trait using:

  summary(Pyr.1.glm)

Call:
glm(formula = Pyrale ~ Trait, family = poisson, data = DataRav)

Deviance Residuals: 
Min 1Q Median 3Q Max 
-1.7117 -0.8944 -0.6237 0.6390 1.5224 

Coefficients:
Estimate Std. Error z value Pr(|z|) 
(Intercept) 1.3350 0.2294 5.819 5.92e-09 ***
TraitInsFong -2.9444 1.0259 -2.870 0.00410 ** 
TraitInsecticide -2.2513 0.7434 -3.028 0.00246 ** 
TraitTemoin -0.2364 0.3454 -0.684 0.49372 
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 

(Dispersion parameter for poisson family taken to be 1)

Null deviance: 49.813 on 19 degrees of freedom
Residual deviance: 18.532 on 16 degrees of freedom
AIC: 61.85

Number of Fisher Scoring iterations: 5

##

I have therefore two questions:

- Considering the values of estimated coefficients for Trait(i), does it 
mean that the bigger is the coefficient, the lower is the probability 
considering the mathematical expression (exp(-m))?

- How can I check that coefficients are significatively different one from 
each other (as with function TukeyHSD for other models)?


Thanks for you help.

Regards

Ghislain.



-- 
Ghislain Vieilledent
30, rue Bernard Ortet 31 500 TOULOUSE
06 24 62 65 07

[[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] Significant difference of coefficients in glm with factors?

2005-07-22 Thread Ghislain Vieilledent
Hi and sorry to distur,


### Setting #

I'm trying to use glm with factors:

 Pyr.1.glm-glm(Pyrale~Trait,DataRav,family=poisson)
 summary(Pyr.1.glm)

Call:
glm(formula = Pyrale ~ Trait, family = poisson, data = DataRav)

Deviance Residuals: 
Min 1Q Median 3Q Max 
-1.7117 -0.8944 -0.6237 0.6390 1.5224 

Coefficients:
Estimate Std. Error z value Pr(|z|) 
(Intercept) 1.3350 0.2294 5.819 5.92e-09 ***
TraitInsFong -2.9444 1.0259 -2.870 0.00410 ** 
TraitInsecticide -2.2513 0.7434 -3.028 0.00246 ** 
TraitTemoin -0.2364 0.3454 -0.684 0.49372 
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 

(Dispersion parameter for poisson family taken to be 1)

Null deviance: 49.813 on 19 degrees of freedom
Residual deviance: 18.532 on 16 degrees of freedom
AIC: 61.85

Number of Fisher Scoring iterations: 5

 anova(Pyr.1.glm,test=Chisq)
Analysis of Deviance Table

Model: poisson, link: log

Response: Pyrale

Terms added sequentially (first to last)


Df Deviance Resid. Df Resid. Dev P(|Chi|)
NULL 19 49.813 
Trait 3 31.281 16 18.532 7.419e-07

## Question ##

I would like to know if the coefficients for the levels of the factors are 
significatively different from each other and not only from the intercept.

Do you know what function can I use and in which package can I found it?

Thanks very much for you help.

Regards.

Ghislain V.

-- 
Ghislain Vieilledent
30, rue Bernard Ortet 31 500 TOULOUSE
06 24 62 65 07

[[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] Name for factor's levels with contr.sum

2005-07-13 Thread Ghislain Vieilledent
Good morning,

I used in R contr.sum for the contrast in a lme model:

 options(contrasts=c(contr.sum,contr.poly))
 Septo5.lme-lme(Septo~Variete+DateSemi,Data4.Iso,random=~1|LieuDit)
 intervals(Septo5.lme)$fixed
lower est. upper
(Intercept) 17.0644033 23.106110 29.147816
Variete1 9.5819873 17.335324 25.088661
Variete2 -3.3794907 6.816101 17.011692
Variete3 -0.5636915 8.452890 17.469472
Variete4 -22.8923812 -10.914912 1.062558
Variete5 -10.7152821 -1.865884 6.983515
Variete6 0.2743390 9.492175 18.710012
Variete7 -23.7943250 -15.070737 -6.347148
Variete8 -21.7310554 -12.380475 -3.029895
Variete9 -27.9782575 -17.480555 -6.982852
DateSemi1 -5.7903419 -1.547875 2.694592
DateSemi2 3.6571596 8.428417 13.199675
attr(,label)
[1] Fixed effects:

How is it possible to obtain a return with the name of my factor's levels as 
with contr.treatment ?

Thanks for you help.

-- 
Ghislain Vieilledent
30, rue Bernard Ortet 31 500 TOULOUSE
06 24 62 65 07

[[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] Fwd: Plotting confidence intervals for lme

2005-07-07 Thread Ghislain Vieilledent
-- Forwarded message --
From: Ghislain Vieilledent [EMAIL PROTECTED]
Date: 7 juil. 2005 11:38
Subject: Re: [R] Plotting confidence intervals for lme
To: Spencer Graves [EMAIL PROTECTED]

That's what I was looking for. Thanks a lot!

That's true units are mixing and that values of coef depend on the contrasts 
but I want to use this graph in order to compare levels' coefficient of each 
of the factor taken independantly, not to compare factors' coefficients to 
eachothers. Does it mean something?

Thanks again. 

Ghislain Vieilledent.



2005/7/6, Spencer Graves [EMAIL PROTECTED]:
 
 Consider the following extension of an example in ?lme:
 
 fm2 - lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
 int - intervals(fm2)
 class(int$fixed)
 kf - dim(int$fixed)[1] 
 plot(int$fixed[,2], kf:1,
 xlab=x, ylab=, xlim=range(int$fixed),
 axes=FALSE)
 axis(1)
 axis(2, kf:1, dimnames(int$fixed)[[1]])
 segments(int$fixed[,1], kf:1,
 int$fixed[,3], kf:1) 
 abline(v=0)
 
 However, we are mixing units, i.e., the units for the intercept are
 distance, while for age are distance/time, and the interpretation
 of the coefficient of a factor like Sex depends on contrasts used. 
 Thus, I don't know how much sense it makes to prepare plots like this.
 
 For similar plots that make more sense, see Pinheiro and Bates (2000
 Mixed-Effects Models in S and S-PLUS (Springer).
 
 spencer graves 
 
 Ghislain Vieilledent wrote:
 
  Hello and sorry to disturb.
 
  I'm trying to plot the confidence intervals for the fixed effects of a 
 lme.
  I want to obtain graphically, if it is possible, a bar with Estimate, 
 upper 
  and lower CI for each level of the factors.
 
  I know how to do for a lm model but for a lme one, I tried with
  plot(intervals(...)) and plot(ci(...)) from the gmodels package but it
  doesn't work well. 
 
  Thanks for you help and have a good day.
 
 
 --
 Spencer Graves, PhD
 Senior Development Engineer
 PDF Solutions, Inc.
 333 West San Carlos Street Suite 700
 San Jose, CA 95110, USA
 
 [EMAIL PROTECTED]
 www.pdf.com http://www.pdf.com http://www.pdf.com
 Tel: 408-938-4420
 Fax: 408-280-7915 
 



-- 
Ghislain Vieilledent
30, rue Bernard Ortet 31 500 TOULOUSE
06 24 62 65 07 


-- 
Ghislain Vieilledent
30, rue Bernard Ortet 31 500 TOULOUSE
06 24 62 65 07

[[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] Plotting confidence intervals for lme

2005-07-06 Thread Ghislain Vieilledent
Hello and sorry to disturb.

I'm trying to plot the confidence intervals for the fixed effects of a lme.
I want to obtain graphically, if it is possible, a bar with Estimate, upper 
and lower CI for each level of the factors.

I know how to do for a lm model but for a lme one, I tried with 
plot(intervals(...)) and plot(ci(...)) from the gmodels package but it 
doesn't work well.

Thanks for you help and have a good day.

-- 
Ghislain Vieilledent
30, rue Bernard Ortet 31 500 TOULOUSE
06 24 62 65 07

[[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] Linear Models with mean as Intercept.

2005-06-30 Thread Ghislain Vieilledent
Dear advanced statisticians,

***Objectif

I try to set up linear models with mean as intercept:
Answer: y
Variable: x, as factor of two modalities: x(1), x(2).

I would like to have a model as:
y = mean(y)+A(i)+residuals,
with i in (1,2) and A(1) coefficient for x(1) and A(2) coefficient for x(2).

***Trials in R***

## Firstly:

I write in R:
 Model-lm(y~x,Data)
 summary(Model)
...
I've got the coefficients for:
- the intercept (x(1) as been choosen) that we can call B(1)
- the second modality: x(2) that we can call B(2)

If I have well understood we have for the model and predictions:
if x(1): y=B(1)
if x(2): y=B(1)+B(2)
which is quite different as y=mean(y)+A(i)

## Secondly
I tried to skip the intercept
 Model2-lm(y~0+x,Data)
 summary(Model2)
...
I've got the coefficients for:
- the first modality: x(1) that we can call C(1)
- the second modality: x(2) that we can call C(2)

And the model and predictions, if I'm right, are:
if x(1): y=C(1)
if x(2): y=C(2)

*** Questions ***
How can I obtain a predictive model y=mean(y)+A(i) ?
Is it possible to settle mean(y) as intercept?

Thanks for your help.

Ghislain V., retarded statistician.

__
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] Selecting rows regarding the frequency of a factor variable.

2005-06-29 Thread Ghislain Vieilledent
Hi and sorry to disturb,

I'll try to be as clear as possible:
I want to select rows of a data frame called Data2.Iso regarding the 
frequency of a factor variable called Variete that I want =4.

I used function table to have the frequency:
  FRAMEVARIETE-as.data.frame(table(Data2.Iso$Variete))
Then I selected the modalities with a frequency =4:
  FRAMEVARIETE2-FRAMEVARIETE[FRAMEVARIETE$Freq=4,]
  as.character(FRAMEVARIETE2[,Variete])

But then, how to select the rows with those modalities?
Does anyone can help me?

Thanks!

Ghislain.

__
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