[R] Converting shapefiles to use in contour plots
Dear R-users, I have imported a shapefile with depth contours for a sea: depths-read.shape(D://My Documents/BarentsSea.shp,dbf.data=T) (This is in mercator projection) **Is there a way to convert this shapefile into a format that it may be plotted on a contour plot?** I wish to add these contours onto a map (already coded using 'maps' package) to map the sea contours with surrounding coastlines and answers to my previous question (thankyou to everyone for that) seem to suggest that using contour plot is the way to go. Thankyou again, Lillian. -- Lillian Sandeman PhD Student School of Biological Sciences University of Aberdeen AB24 2TZ Tel.: 01224 272648 E-mail: [EMAIL PROTECTED] __ 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 shapefiles on existing maps
Dear All, This is probably a very basic question but: I have plotted a map of the Barents Sea and surrounding coastline using: map('worldHires',ylim=c(50,85),xlim=c(5,65),fill=T,resolution=0) map.axes() map.scale(x=30,metric=T) Next, I imported a shapefile with depth contours for the sea: contours-read.shape(D://My Documents/BarentsSea.shp,dbf.data=T) (This is in mercator projection). Despite extensive searches of the help files and R site, I cannot find a way to plot the contours onto the map. Does anyone have any suggestions? Thankyou for you help, Lillian. -- Lillian Sandeman PhD Student School of Biological Sciences University of Aberdeen AB24 2TZ Tel.: 01224 272648 E-mail: [EMAIL PROTECTED] __ 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] logLik == -Inf in gls
I am trying to fit a generalised least squares model using gls in the nlme package. The model seems to fit very well when I plot the fitted values against the original values, and the model parameters have quite narrow confidence intervals (all are significant at p5%). The problem is that the log likelihood is always given as -Inf. This doesn't seem to make sense because the model seems to fit my data so well. I have checked that the residuals are stationary using an adf test. I can't work out whether - the model really doesn't fit at all - there is something in my data that stops the implementation of logLik working correctly (the -Inf value says the calculation hasn't worked) Possible causes are: - There are lots of NAs in my data (model and response variables) - There is some autocorrelation in the data that is not accounted for by the model (most is accounted for). But, I've tried recreating the problem using a simpler data set, and have never found the same problem. The command I use to fit the model is... result2 - gls(lci4150 ~ propCapInStomachs + temperature + as.factor(monthNumber) + lagLci1 + lagcap1 + lagcap2, data = monthly, subset = subset1985, na.action = na.approx, weights = varFixed( ~ 1/numob4150) ) The output I get is... Generalized least squares fit by REML Model: lci4150 ~ propCapInStomachs + temperature + as.factor(monthNumber) + lagLci1 + lagcap1 + lagcap2 Data: monthly Subset: subset1985 AIC BIC logLik Inf Inf -Inf Variance function: Structure: fixed weights Formula: ~1/numob4150 Coefficients: Value Std.Error t-value p-value (Intercept) -0.3282412 0.5795665 -0.566356 0.5717 propCapInStomachs 0.0093283 0.0039863 2.340107 0.0202 temperature 0.4342514 0.1526104 2.845490 0.0048 as.factor(monthNumber)2 0.3990717 0.3869991 1.031195 0.3036 as.factor(monthNumber)3 1.3788334 0.3675690 3.751223 0.0002 as.factor(monthNumber)4 1.4037195 0.3857764 3.638686 0.0003 as.factor(monthNumber)5 0.9903316 0.3436177 2.882074 0.0043 as.factor(monthNumber)6 0.3453741 0.3043698 1.134719 0.2577 as.factor(monthNumber)7 0.3948442 0.3035142 1.300909 0.1946 as.factor(monthNumber)8 0.5021812 0.3532413 1.421638 0.1565 as.factor(monthNumber)9 -0.0794319 0.3598981 -0.220707 0.8255 as.factor(monthNumber)10 0.3536805 0.3790538 0.933061 0.3518 as.factor(monthNumber)11 0.7874834 0.3557116 2.213826 0.0278 as.factor(monthNumber)12 0.1854279 0.3178320 0.583415 0.5602 lagLci1 0.5488437 0.0576144 9.526151 0. lagcap1 0.0110994 0.0043669 2.541714 0.0117 lagcap2 -0.0088080 0.0041099 -2.143127 0.0332 Does anyone have any suggestions of how I can get a meaningful value for logLik? Or some other way that I can compare models. Thankyou, Lillian. -- Lillian Sandeman PhD Student School of Biological Sciences University of Aberdeen AB24 2TZ Tel.: 01224 272648 E-mail: [EMAIL PROTECTED] __ 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] logLik == -Inf in gls
I am trying to fit a generalised least squares model using gls in the nlme package. The model seems to fit very well when I plot the fitted values against the original values, and the model parameters have quite narrow confidence intervals (all are significant at p5%). The problem is that the log likelihood is always given as -Inf. This doesn't seem to make sense because the model seems to fit my data so well. I have checked that the residuals are stationary using an adf test. I can't work out whether - the model really doesn't fit at all - there is something in my data that stops the implementation of logLik working correctly (the -Inf value says the calculation hasn't worked) Possible causes are: - There are lots of NAs in my data (model and response variables) - There is some autocorrelation in the data that is not accounted for by the model (most is accounted for). But, I've tried recreating the problem using a simpler data set, and have never found the same problem. The command I use to fit the model is... result2 - gls(lci4150 ~ propCapInStomachs + temperature + as.factor(monthNumber) + lagLci1 + lagcap1 + lagcap2, data = monthly, subset = subset1985, na.action = na.approx, weights = varFixed( ~ 1/numob4150) ) The output I get is... Generalized least squares fit by REML Model: lci4150 ~ propCapInStomachs + temperature + as.factor(monthNumber) + lagLci1 + lagcap1 + lagcap2 Data: monthly Subset: subset1985 AIC BIC logLik Inf Inf -Inf Variance function: Structure: fixed weights Formula: ~1/numob4150 Coefficients: Value Std.Error t-value p-value (Intercept) -0.3282412 0.5795665 -0.566356 0.5717 propCapInStomachs 0.0093283 0.0039863 2.340107 0.0202 temperature 0.4342514 0.1526104 2.845490 0.0048 as.factor(monthNumber)2 0.3990717 0.3869991 1.031195 0.3036 as.factor(monthNumber)3 1.3788334 0.3675690 3.751223 0.0002 as.factor(monthNumber)4 1.4037195 0.3857764 3.638686 0.0003 as.factor(monthNumber)5 0.9903316 0.3436177 2.882074 0.0043 as.factor(monthNumber)6 0.3453741 0.3043698 1.134719 0.2577 as.factor(monthNumber)7 0.3948442 0.3035142 1.300909 0.1946 as.factor(monthNumber)8 0.5021812 0.3532413 1.421638 0.1565 as.factor(monthNumber)9 -0.0794319 0.3598981 -0.220707 0.8255 as.factor(monthNumber)10 0.3536805 0.3790538 0.933061 0.3518 as.factor(monthNumber)11 0.7874834 0.3557116 2.213826 0.0278 as.factor(monthNumber)12 0.1854279 0.3178320 0.583415 0.5602 lagLci1 0.5488437 0.0576144 9.526151 0. lagcap1 0.0110994 0.0043669 2.541714 0.0117 lagcap2 -0.0088080 0.0041099 -2.143127 0.0332 Does anyone have any suggestions of how I can get a meaningful value for logLik? Or some other way that I can compare models. Thankyou for your help, Lillian. -- Lillian Sandeman PhD Student School of Biological Sciences University of Aberdeen AB24 2TZ Tel.: 01224 272648 E-mail: [EMAIL PROTECTED] __ 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] adf test and cross-correlation with missing values
Dear List, I have multiple time series, all of which (excepting 1) have missing values. These run for ~30 years, with monthly sampling. I need to determine stationarity, and have tried to use the Augmented Dickey-Fuller test (adf.test), but this cannot handle missing values. The same problem occurs when attempting cross-correlation (ccf). Could someone please suggest any suitable functions in R to check for stationarity and to look at cross-correlation when NAs are present in a time series (and also, which packages these would be in) - or, do I have to interpolate the missing values first in order to perform these tests on my time series? Thankyou, Lillian. __ 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] Time series ARIMAX and multivariate models
Dear List, The purpose of this e-mail is to ask about R time series procedures - as a biologist with only basic time series knowledge and about a year's experience in R. I have been using ARIMAX models with seasonal components on seasonal data. However I am now moving on to annual data (with only 34 time points) and understand that ARIMA is not suitable for these shorter time periods - does R have other, more robust, methods? I have tried looking through the R help pages documentation for packages but am unsure what model type is suitable. Secondly, I wish to start building multivariate time series models in R to look at how fish condition (for several sizes of fish) is affected by environmental factors and numbers of prey. It would be great if someone could suggest what R packages/documentation would be useful to research? Thankyou, Lillian. __ 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] Missing Values
I have just started using R for my PhD. I am importing my data from Excel via notepad into Word. Unfortunately, my data has many missing values. I have put '.' and this allowed me to import the data into R. However, I now want to interpolate these missing values. Please can someone give me some pointers as to the method/code I could use? Thankyou, Lillian. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html