I am trying to analyse Lobster egg development between the months of January and June by measuring the eyespot to gather the perkins eye index (PEI).
I have a dataset with two variables, Month, ranging from January and June, and PEI, ranging from 1 to ~600. Typically PEI is around 300-600, however the eyespot hadn't devloped for some eggs so they were assigned a value of 1. I have a range of 40 to 240 PEI values for each month and my data set looks like this...
I am using the mgcv package and i am trying to fit a GAM.
My issue is i keep getting this error after i attempt to fit the GAM:
Error in smooth.construct.tp.smooth.spec(object, dk$data, dk$knots) :
NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning messages:
1: In mean.default(xx) : argument is not numeric or logical: returning NA
2: In Ops.factor(xx, shift[i]) : ‘-’ not meaningful for factors
I ensured that Month is a factor, that there are 6 levels in the correct order, and i have checked for missing values, and now i am not sure what is wrong.
Please advise on whether my dataset is fit for the GAM process or explain how i should do this differently, thank you**
The code i used is as follows....
library(mgcv)
data <- read.csv("PEI.csv")
Month <- c("January", "February", "March", "April", "May", "June")
Month <- factor(Month, levels = c("January", "February", "March", "April", "May", "June"))
gam <- gam(PEI ~ s(Month), data = data)
I then get the error....
Error in smooth.construct.tp.smooth.spec(object, dk$data, dk$knots) :
NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning messages:
1: In mean.default(xx) : argument is not numeric or logical: returning NA
2: In Ops.factor(xx, shift[i]) : ‘-’ not meaningful for factors