[R] Transfer function observed vs predicted values graph problem

2011-02-23 Thread mdc

Hi, 
I am trying to make a palaeoenvironmental transfer function using the R
package rioja that predicts the water-table (measured as depth to the water
table) of an area given the testate amoebae that are found there. I've
carried out weighted averaging of the data and am trying to produce a graph
that shows the observed water-table versues the model's predicted values.
Following the instructions in the rioja help booklet (see below), I end up
with a graph where the origin is not at the bottom left of the diagram, i.e.
the graph is showing some values that suggest that the water table is, say,
1m above ground. 
I've tried entering the water-tables as negative values but the same thing
happens. 
Does anybody know if there something I'm missing out? Or is there a way
that, if the values returned are less than 0, then they can automatically be
put just as 0?
Any help would be most appreciated, 
Thank you, 
Matthew


My environmental matrix (x) is:
SampleId WTD Moisture pH EC
1 1 20 91.72700 3.496674  85.02688
2 2  2 93.88913 3.550794  85.69465
3 3 26 90.30269 3.948559 113.19206
4 4  5 94.14427 3.697213  48.56375
5 5 30 90.04269 3.745020 108.57278

90 GAL_15 70 94.07849 3.777932  66.77673

The species matrix (y) contains the abundance of 32 species over 90 sites,
set out like this
F1 AmpFlav AmpWri ArcCat ArcDis
1 1 22.2929936 0.000 0.000 0.000
2 2 30.9677419 0.000 0.000 3.2258065


fit - WA(y, x, tolDW = FALSE, use.N2=TRUE, check.data=TRUE, lean=FALSE)
# plot predicted vs. observed
plot(fit)
plot(fit, resid=TRUE)
# Water-table reconstruction
pred - predict(fit, y)
#plot the reconstruction
plot(sites, pred$fit[, 1], type=b)
# cross-validation model using bootstrapping
fit.xv - crossval(fit, cv.method=boot, nboot=1000)
par(mfrow=c(1,2))
plot(fit)
plot(fit, resid=TRUE)
plot(fit.xv, xval=TRUE)
plot(fit.xv, xval=TRUE, resid=TRUE)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Transfer-function-observed-vs-predicted-values-graph-problem-tp3320663p3320663.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] Rioja package, creating transfer function, WA, Error in FUN

2011-02-11 Thread mdc

Dear Peter,
Thank you very much for your suggestion, I went through the matrices and
removed the headings for pH, WTD etc and did the same for the site names,
which I made purely numerical, and now the WA function is working,
Thanks again!
Matthew

On Fri, Feb 11, 2011 at 12:44 AM, Peter Ehlers [via R] 
ml-node+3300569-1208751190-212...@n4.nabble.com wrote:

 On 2011-02-10 09:40, mdc wrote:

 
  Hi, I am a new R user and am trying to construct a palaeoenvironmental
  transfer function (weighted averaging method) using the package rioja.
  I've managed to insert the two matrices (the species abundance and the
  environmental data) and have assigned them to the y and x values
  respectively. When I try and enter the 'WA' function though, I get an
 'Error
  in FUN' message (see below for full values). Alas, I do not know what
 this
  means and have struggled to find similar problems to this online. Is
 there a
  step I've missed out between assigning the matrices and the WA function?
 
  SWED=odbcConnectExcel(file.choose())   (SWED is the environmental
 data
  file)
  sqlTables(SWED)
  Env=sqlFetch(SWED, Sheet1)
  odbcClose(SWED)
  Env
 
  SampleId WTD  Moisture   pH EC
  1  N1_1   20 91.72700 3.496674  85.02688
  2  N1_22 93.88913 3.550794  85.69465
  3  N1_3   26 90.30269 3.948559 113.19206
  4  N1_45 94.14427 3.697213  48.56375
  5  N1_5   30 90.04269 3.745020 108.57278
  
  90 GAL_15 70 94.07849 3.777932  66.77673
 
 
  STEST=odbcConnectExcel(file.choose())
  sqlTables(STEST)  (STEST is the
  species abundance file)
  Spe=sqlFetch(STEST, Sheet8)
  odbcClose(STEST)
  Spe
 
  (The species data contains the abundance of 32 species over 90 sites, set

  out like this)
  F1AmpFlavAmpWri  ArcCat   ArcDis
  1N1_1 22.2929936 0.000  0.000  0.000
  2N1_2 30.9677419 0.000  0.000  3.2258065
 
  library(rioja)
  y-as.matrix(Spe)
  x-as.matrix(Env)
 
  WA(y, x, tolDW = FALSE, use.N2=TRUE, check.data=TRUE, lean=FALSE)
  (the
  command from the WA section of the rioja booklet)
  Error in FUN(newX[, i], ...) : invalid 'type' (character) of argument

 Well, the error message is fairly clear: you're feeding in
 something of type 'character' where something else (presumably)
 numeric is wanted.

 I don't use rioja, but a quick glance at the documentation
 for WA shows that x should be 'a vector of environmental
 values to be modelled'. The example uses pH which is almost
 surely not a character vector.

 Your x is a *matrix* of *character* values. Possibly, you
 want to pull, say, pH out of your Env, convert to numeric
 and try that. Ditto for the other variables.

 If the above is total nonsense, please forgive my rioja
 ignorance and wait for more cogent advice from
 someone more knowledgeable than I.

 Peter Ehlers

 
 
  Any help would be most appreciated,
  Best wishes,
  Matthew

 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=3300569i=0mailing 
 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.


 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://r.789695.n4.nabble.com/Rioja-package-creating-transfer-function-WA-Error-in-FUN-tp3299636p3300569.html
  To unsubscribe from Rioja package, creating transfer function, WA, Error
 in FUN, click 
 herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3299636code=bWF0dC5kLmNvZUBnbWFpbC5jb218MzI5OTYzNnwyMDMzMDk2ODg2.



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Rioja-package-creating-transfer-function-WA-Error-in-FUN-tp3299636p3302063.html
Sent from the R help mailing list archive at Nabble.com.

[[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] Rioja package, creating transfer function, WA, Error in FUN

2011-02-10 Thread mdc

Hi, I am a new R user and am trying to construct a palaeoenvironmental
transfer function (weighted averaging method) using the package rioja.
I've managed to insert the two matrices (the species abundance and the
environmental data) and have assigned them to the y and x values
respectively. When I try and enter the 'WA' function though, I get an 'Error
in FUN' message (see below for full values). Alas, I do not know what this
means and have struggled to find similar problems to this online. Is there a
step I've missed out between assigning the matrices and the WA function?  

 SWED=odbcConnectExcel(file.choose())   (SWED is the environmental data
 file)
 sqlTables(SWED)
 Env=sqlFetch(SWED, Sheet1)
 odbcClose(SWED)
 Env

   SampleId WTD  Moisture   pH EC 
1  N1_1   20 91.72700 3.496674  85.02688
2  N1_22 93.88913 3.550794  85.69465
3  N1_3   26 90.30269 3.948559 113.19206
4  N1_45 94.14427 3.697213  48.56375
5  N1_5   30 90.04269 3.745020 108.57278

90 GAL_15 70 94.07849 3.777932  66.77673


 STEST=odbcConnectExcel(file.choose())
 sqlTables(STEST)  (STEST is the
 species abundance file)
 Spe=sqlFetch(STEST, Sheet8)
 odbcClose(STEST)
 Spe

(The species data contains the abundance of 32 species over 90 sites, set
out like this)
   F1AmpFlavAmpWri  ArcCat   ArcDis 
1N1_1 22.2929936 0.000  0.000  0.000
2N1_2 30.9677419 0.000  0.000  3.2258065

 library(rioja)
 y -as.matrix(Spe)
 x -as.matrix(Env)

 WA(y, x, tolDW = FALSE, use.N2=TRUE, check.data=TRUE, lean=FALSE)(the
 command from the WA section of the rioja booklet)
Error in FUN(newX[, i], ...) : invalid 'type' (character) of argument


Any help would be most appreciated, 
Best wishes, 
Matthew
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Rioja-package-creating-transfer-function-WA-Error-in-FUN-tp3299636p3299636.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.