Re: [R-sig-eco] number of observations used in scatterplot.matrix()

2011-01-21 Thread Luciano Selzer
Hi, maybe something like this should do the trick:

  n - nrow(x)

 txt - paste(rho=, txt, \np=,pval, n=, n, sep=)


HTH
Luciano


2011/1/21 Maria Dulce Subida mdsub...@icman.csic.es

 Dear all,

 I have a script (please see below) that gives a scatter plot matrix on
 the upper panel, and the spearman rho and probability values on the
 lower panel. It also gives the density function of each variable in the
 diagonal, adds a smoother and a linear regression line to each scatter
 plot, and puts significant spearman coefficient values in red.
 Now I would like to add to the lower panel information, the value of
 n=number of observations used to calculate the spearman correlation
 coefficient. Does anyone know I could I add that parameter to my
 function panel.cor?

 Thank you!

 Kind regards,

 Dulce

 

 panel.cor - function (x, y,method=spearman,digits=2,...)
 {
 points(x,y,type=n);
 usr - par(usr); on.exit(par(usr))
 par(usr = c(0, 1, 0, 1));
 correl - cor.test(x, y,method=method);
 r=correl$estimate;
 pval=correl$p.value;
 color=black;
 if (pval0.05) color=red;
 txt - format(r,digits=2)
 pval - format(pval,digits=2)

   n - nrow(x)

 txt - paste(rho=, txt, \np=,pval, n=, n, sep=)
 text(0.5, 0.5, txt,col=color)
 }

 scatterplot.matrix (~ var1 + var2 + var3 , data=mydata,
 main=Mydata, smooth=TRUE,
 lower.panel=panel.cor, pch=20, cex=0.5,
 col=c(red,black),cex.labels=1, font.labels=2, lwd=0.5)





[[alternative HTML version deleted]]

 ___
 R-sig-ecology mailing list
 R-sig-ecology@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] mrpp between pairs of factor levels

2010-09-24 Thread Luciano Selzer
Cristabel, I don't know if this what you are after. Why don't you just use
the subset of data you are interested in.

mrpp(data=subset(spp, mhab == b  mhab == nd), grouping=mhab,
dist=bray,
permutations=1000)

or

spp1 - subset(spp, mhab == b  mhab == nd)
spp1$mhab - factor(spp1$mhab) #to drop unused levels

mrpp(data=spp1, grouping=mhab, dist=bray,
permutations=1000)

HTH

Luciano


2010/9/24 cristabel.du...@waldbau.uni-freiburg.de

 Dear list,

 I'm performing a mrpp analysis for my data (spp), the
 grouping factor is mhab.
 mhab has five levels: b  br c  nd
nongap t

 So, for a mrpp with factor mhab with all levels I'm doing:
 mrpp(data=spp, grouping=mhab, dist=bray,
 permutations=1000)


BUT now I want is to perform a mrpp with only levels b
 and nd.

 I tried several ways without success:
 mrpp(data=spp, grouping=c(mhab==b  nd) , dist=bray,
 permutations=1000)
 mrpp(data=spp, grouping=c(mhab==b  mhab==nd) ,
 dist=bray, permutations=1000)
 mrpp(data=spp, grouping=levels(which(envno34$mhab== b) 
 which(envno34$mhab== b)), dist=bray, permutations=1000)

 I got this errors:
 - Error in x * w : non-numeric argument to binary operator
 - Error in levels(mhab(which(mhab == b)  which(mhab ==
  :
   attempt to apply non-function
 - Error in mhab == b  nd :
   operations are possible only for numeric, logical or
 complex types
 ...etc...etc..

 I think it should be possible to choose the factor levels
 which I want to work with, otherwise I should fix this
 issue from
 my species and environmental matrices.

 I appreciate your help!
 Thank you :-)
 Cristabel.

 Cristabel Durán Rangel. PhD Student.
 Institute of Silviculture. Faculty of Forest and
 Environmental Sciences. University of Freiburg.
 Germany
 Telf: +49 (761) 203 8604 (ofc)

 „Man lernt die Physiognomie einer Landschaft desto besser
 kennen, je genauer man die einzelnen Züge auffaßt, sie
 untereinander vergleicht und so auf dem Wege der Analysis
 den Quellen der Genüsse nachgeht, die uns das große
 Naturgemälde bietet.“
Alexander von Humboldt, 1799

 ___
 R-sig-ecology mailing list
 R-sig-ecology@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Function predict

2010-07-07 Thread Luciano Selzer
Hi Manuel, your problem is that the new variables you created are of numeric
type, while the model was fitted using factor. So the fix is to convert the
new variables to factors so the type matchs
Luciano


2010/7/7 Manuel Spínola mspinol...@gmail.com

 Dear list members,

 I am fitting a logistic regression with 5 explanatory factors (which I
 converted to factors):

 mod6 = glm(condicion ~ iluminacion + animales + cielo.raso + piso +
 paredes, family=binomial, data=reglog)

 I want to obtain the predicted probabilities and the se using the function
 predict for some combination of the factors.

 iluminacion = 1
 animales = 0
 cielo.raso = 0
 piso = 0
 paredes = 0

 newdata1 = data.frame(iluminacion, animales, cielo.raso, piso, paredes)

 newdata1$cond = predict(mod6, newdata = newdata1, type=response)

  newdata1$cond = predict(mod6, newdata = newdata1, type=response)
 Aviso en model.frame.default(Terms, newdata, na.action = na.action, xlev =
 object$xlevels) :
  variable 'iluminacion' is not a factor
 Aviso en model.frame.default(Terms, newdata, na.action = na.action, xlev =
 object$xlevels) :
  variable 'animales' is not a factor
 Aviso en model.frame.default(Terms, newdata, na.action = na.action, xlev =
 object$xlevels) :
  variable 'cielo.raso' is not a factor
 Aviso en model.frame.default(Terms, newdata, na.action = na.action, xlev =
 object$xlevels) :
  variable 'piso' is not a factor
 Aviso en model.frame.default(Terms, newdata, na.action = na.action, xlev =
 object$xlevels) :
  variable 'paredes' is not a factor
 Error: variables 'iluminacion', 'animales', 'cielo.raso', 'piso', 'paredes'
 were specified with different types from the fit

 I don't understand what is wrong.
 Any help will be appreciated.

 Best,

 Manuel

 --
 Manuel Spínola, Ph.D.
 Instituto Internacional en Conservación y Manejo de Vida Silvestre
 Universidad Nacional
 Apartado 1350-3000
 Heredia
 COSTA RICA
 mspin...@una.ac.cr
 mspinol...@gmail.com
 Teléfono: (506) 2277-3598
 Fax: (506) 2237-7036

 ___
 R-sig-ecology mailing list
 R-sig-ecology@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Changing the reference level of a factor

2010-05-18 Thread Luciano Selzer
Manuel, in order to save the changes you have to assign it to the data
frame.
Here is how you should do it.

nidprop$treatment - relevel(nidprop$treatment, ref=c, data=nidprop)

Luciano Selzer

2010/5/18 Manuel Spínola mspinol...@gmail.com

 Dear list members,

 I am trying to change the reference level of a factor but when I run a
 model with the lm function the new order it does not taking place (I still
 have the old order of the levels).

  relevel(nidprop$treatment, ref=c, data=nidprop)
 [1] a a a a b b b b c c c c
 Levels: c a b

  modelo1 = lm(hight ~ treatment, data = nidprop)

  summary(modelo1)

 Call:
 lm(formula = hight ~ treatment, data = nidprop)

 Residuals:
   Min  1Q  Median  3Q Max
 -1.6052 -1.0626 -0.0950  0.9228  3.0768

 Coefficients:
  Estimate Std. Error t value Pr(|t|)  (Intercept) 37.9140
 0.7368  51.461 1.98e-12 ***
 treatment[T.b]  -0.2298 1.0419  -0.221   0.8304  treatment[T.c]
  -3.1133 1.0419  -2.988   0.0153 *
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

 Residual standard error: 1.474 on 9 degrees of freedom
 Multiple R-squared: 0.552,  Adjusted R-squared: 0.4525
 F-statistic: 5.545 on 2 and 9 DF,  p-value: 0.02696


 Any idea why?

 Best,

 Manuel Spínola

 --
 Manuel Spínola, Ph.D.
 Instituto Internacional en Conservación y Manejo de Vida Silvestre
 Universidad Nacional
 Apartado 1350-3000
 Heredia
 COSTA RICA
 mspin...@una.ac.cr
 mspinol...@gmail.com
 Teléfono: (506) 2277-3598
 Fax: (506) 2237-7036

 ___
 R-sig-ecology mailing list
 R-sig-ecology@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] nested mixed model?

2010-02-03 Thread Luciano Selzer
Hi, I'm by no means an expert, just an PhD student. But in my humble opinion
shouldn't you consider the individual effect? I think that the microtexture
could be influenced by this.
Luciano


2010/2/3 Mauricio Cifuentes mcifu...@gmail.com

 Hi everybody,

 I am trying to fit a model in R using the lme() function. I would like
 to have your opinion about what I did and if there are better ways to
 resolve this analysis. First Let me explain you how look the data that
 we are analyzing. We want to compare the tooth microtexture of four
 species of ungulates.

 For that we have taken pictures in eight different points within each
 tooth of one individual. We used as many teeth as were available for
 each individual taken in account their position and at the same time
 separating them by the place they were located (mandible: down tooth;
 maxilla: upper tooth).

 I am not an expert, but until here the model looks as nested design,
 please let me know if I am wrong. In summary we have the following
 hierarchy arrangement:

 Species (4 species)  bone(mandible or maxilla)  tooth  points within
 each tooth (8 points).

 I have fitted this model using: lme(response ~ species, data=tooth,
 random=~1|bone/tooth/points,na.action=na.omit)

 I will be really grateful if you can give me your opinion about that.

 Best wishes

 Mauro

 ___
 R-sig-ecology mailing list
 R-sig-ecology@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


[[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology