Skip to content

adehabitat: GNESFA - first and last axes

5 messages · Maria Zwart, Johannes Radinger, Chris Howden +1 more

#
Dear list,

I am looking at habitat selection in chaffinches with point data (type I study).
I am trying to do the GNESFA (package adehabitatHS). All goes well up to where the function asks to choose the number of first and last axes. Although there is some information about this in the supplied manual supplied by the package (see below), my knowledge of the function is not enough to be able to understand which axes to choose.

"The first axes correspond to the directions where the utilization distribution as a whole is the furthest from the centroid of the availability distribution (these directions often correspond to directions where the marginality is strong; i.e. the criterion y1 defined previously is maximized). The last axes correspond to the directions where the width of the utilization distribution is the smallest relative to the width of the availability distribution (these directions often correspond to directions where the specialization is strong, i.e. the criterion y1 defined previously is minimized)."

Attached are the eigenvalues plots that I get. My interpertation is that for the first axes I have to choose 3, because after that there is a huge drop. And for the last axes I choose 16, because there is an increase there. The results indicate that they select coniferous woodland and mixed woodland, which makes sense since chaffinches are usually found in those habitats. Any advice is greatly appreciated!

Code:
cp <- count.points(locs, towlaw_spdf) #locs are the coordinates of the locations where the chaffinches are. towlaw_spdf is a SpatialPixelsDataFrame, a map with the different habitat variables.
tab <- slot(towlaw_spdf, "data")
pr <- slot(cp, "data")[, 1]
histniche(tab, pr)
pc <- dudi.pca(tab, scannf = FALSE)
gn <- gnesfa(pc, Focus = pr)

Many thanks,

Mieke
Maria Zwart
PhD student
Room 4.65
School of Biology
Ridley 2
Newcastle University
Newcastle upon Tyne
NE1 7RU
United Kingdom
3 days later
#
Hi UseRs,

I calculated with lm(Y~X1+X2) successfully a linear regression.
Based on this linear regression with multiple independent variables
I'd like to calculate manually prediction intervals. Therefore I have a few
questions:

1) I want a prediction interval for Y (like Y+-PI) for a given value
for X1 and X2.
2) I want to calculate the predicition intervall for Y by hand (either
with the mathematical functions of R or with python etc.

So I think I have to extract the prediction interval for the single
regression parameters (intercept and slopes) from the lm model.

I tried to google for a simple solution but wasn't succesfully yet.
I think following link: Prediction interval in Regression analysis explains very well
what I want to do.

There it says: "...one may use the standard error of the estimates for the intercept and slope ( and ) to compute a prediction interval". So is that the right approach?
If yes how can I get the standard error for a and b and which formula
has to used for the calculation?


Thank you very much in advance

Have a nice sunday!

cheers
Johannes
#
Hi Johannes,

predict() will give u SE's and confidence intervals.

U can either use the original data as an input and get a prediction for
all the original data points. Or create an input data set and get
predictions for them.

If your doing an ANOVA type analysis with discrete factors I often use
expand.grid to quickly get a matrix for all combinations. So something
like this
(predict.ci <- data.frame(expand.grid(model$xlevels), predict(model,
expand.grid(model$xlevels), interval="conf")))


There's also confint() which is for single parameters.


Chris Howden B.Sc. (Hons) GStat.
Founding Partner
Evidence Based Strategic Development, IP Commercialisation and Innovation,
Data Analysis, Modelling and Training
(mobile) 0410 689 945
(fax) +612 4782 9023
chris at trickysolutions.com.au




Disclaimer: The information in this email and any attachments to it are
confidential and may contain legally privileged information.?If you are
not the named or intended recipient, please delete this communication and
contact us immediately.?Please note you are not authorised to copy, use or
disclose this communication or any attachments without our consent.
Although this email has been checked by anti-virus software, there is a
risk that email messages may be corrupted or infected by viruses or other
interferences. No responsibility is accepted for such interference. Unless
expressly stated, the views of the writer are not those of the company.
Tricky Solutions always does our best to provide accurate forecasts and
analyses based on the data supplied, however it is possible that some
important predictors were not included in the data sent to us. Information
provided by us should not be solely relied upon when making decisions and
clients should use their own judgement.


-----Original Message-----
From: r-sig-ecology-bounces at r-project.org
[mailto:r-sig-ecology-bounces at r-project.org] On Behalf Of Johannes
Radinger
Sent: Sunday, 16 October 2011 10:45 PM
To: r-sig-ecology at r-project.org
Subject: [R-sig-eco] Calculate Prediction Interval for Regression by
hand...

Hi UseRs,

I calculated with lm(Y~X1+X2) successfully a linear regression.
Based on this linear regression with multiple independent variables
I'd like to calculate manually prediction intervals. Therefore I have a
few
questions:

1) I want a prediction interval for Y (like Y+-PI) for a given value
for X1 and X2.
2) I want to calculate the predicition intervall for Y by hand (either
with the mathematical functions of R or with python etc.

So I think I have to extract the prediction interval for the single
regression parameters (intercept and slopes) from the lm model.

I tried to google for a simple solution but wasn't succesfully yet.
I think following link: Prediction interval in Regression analysis
explains very well
what I want to do.

There it says: "...one may use the standard error of the estimates for the
intercept and slope ( and ) to compute a prediction interval". So is that
the right approach?
If yes how can I get the standard error for a and b and which formula
has to used for the calculation?


Thank you very much in advance

Have a nice sunday!

cheers
Johannes

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
#
Hi again,

thank you all for you tips with predict, predict.lm etc.
Error for intercept and slopes. With confint I can get confidence
intervals (?) for these parameters for different levels.

I want to calculate it by hand, rather then by using R's predict
function, due to some reasons:

1) I want to get the mathematical background
2) I want to use it in a model outside of grass (python-model, and
I don't want to use a direct interaction python-R)
3) I want to calculate it with simple programming languages (e.g. simplest form of basic etc.)

In wikipedia it says that it is possible to calculate the prediction interval from the standard error of the parameters. So how is that done exactly? Can anyone guide me to the formula? Or is it just 

Y=b+Intercept + (a1+SE(a1))*X1+(a2+SE(a2)*X2 (of course with all variations in plus and minus SE)?

Your help is greatly appreciated!

/johannes

-------- Original-Nachricht --------
--
7 days later
#
Johannes Radinger <JRadinger at ...> writes:
[snip]

  You need to take the covariance of the parameters into account.
Suppose you want to calculate the prediction interval for values
X1=a1, X2=a2.  Form a vector X=c(1,a1,a2) (the first term is for
the intercept).  If you (matrix) multiply this by your parameter vector
beta (X %*% beta), i.e. beta_0 + beta_1*a1+beta_2*a2 
you get your predicted value.  If you have variance-covariance
matrix V for the intercept and slopes (a 3x3 symmetric matrix)
then the variance of the prediction is X %*% V %*% X^T.
  Code following this approach can be found at http://glmm.wikidot.com/faq .