wlgm {FSA}R Documentation

Performs the scale increment model of Weisberg's Linear Growth Models.

Description

Constructs the scale increment model of Weisberg's Linear Growth Models and extracts the results as described in Weisberg (1993).

Usage

  wlgm(formula,data,weights,na.action,sds=NULL,age.first=TRUE)

  ## S3 method for class 'WLGM':
  alias(object,...)

  ## S3 method for class 'WLGM':
  anova(object,object2,object3,...)

  ## S3 method for class 'WLGM':
  boxcox(object,...)

  ## S3 method for class 'WLGM':
  coef(object,what=c("both","age","year"),suppress.msg=FALSE,...)

  ## S3 method for class 'WLGM':
  confint(object,parm=what,level=conf.level,what=c("both","age","year"),
          conf.level=0.95,suppress.msg=FALSE,...)

  ## S3 method for class 'WLGM':
  fit.plot(object,...)

  ## S3 method for class 'WLGM':
  summary(object,...)

Arguments

formula A formula that represents the full Weisberg LGM. See details.
data An optional data frame from which the variables in the formula are found.
weights A numerical vector of weights for the model fit. See details.
na.action a function which indicates what should happen when the data contain NAs. See ?lm for more information.
sds A numerical vector (if data is not NULL) or the name of a vector (if data is provided) containing the standard deviations when a weighted regression on the summarized data is used. See details.
age.first A logical indicating whether the age factor variable was entered first on the right-hand-side of formula.
object A WLGM object (i.e., returned from the wlgm function).
object2 A WLGM object (i.e., returned from the wlgm function). See details.
object3 A WLGM object (i.e., returned from the wlgm function). See details.
what A string indicating which type of coefficients should be extracted. Defaults to “both”. See details.
parm Same as what and SHOULD NOT BE USED. Included for compatability with generic confint function
level Same as conf.level but used for compatability with generic confint function.
conf.level A decimal numeric indicating the level of confidence to use for confidence and prediction intervals.
suppress.msg A logical indicating whether to suppress the message that reminds the user of which term and level has been aliased.
... Additional arguments for methods.

Details

Fish growth is a response to biotic and abiotic environmental factors and some function of attained size or age (Weisberg, 1993). With an assumption that the environmental factors are relatively constant within a year but may vary among years it can be said that fish growth is related to both an age and a year factor. A record of the growth history of a fish is recorded in the increments between annuli on calcified structures under the common assumption that body growth is strongly related to the growth of calci ed structures. Each annular increment in a fish's growth history can be categorized by the age of the fish and the year that the increment was produced on the scale. Weisberg (1993) proposed a linear model (essentially a two-way analysis-of-variance model) that separates the growth increments into a component due to the age of the fish and a component due to the year the increment was created. The base wlgm function fits the models required for this analysis (details below) and the remaining functions detailed here extract specific information from the results of the wlgm function. The Weisberg (1993) reference (below) should be consulted for more details. There is also a vignette – wlgm.pdf – in the docs folder of the installed package.

The models require data in a one-increment-per-line format. This means that each row in the data frame must contain information about only one measured growth increment. Data is typically recorded in one-fish-per-line format and, thus, will have to be reshaped before fitting the linear growth models (see g.reshape). Data is often also recorded as radial measurements (i.e., from the calcified structure center to the distal edge of each annulus) rather than incremental measurements (i.e., from the distal edge of one annulus to the distal edge of the subsequent annulus). The linear growth models require increment measurements; thus, data recorded as radial measurements must be converted to increment measurements (see g.convert).

The wlgm function actually fits two separate linear models. The first model, stored in the $a.lm object, is the full model with an intercept, an age main effect, a year main effect, and an interaction term. This model is primarily used to develop the appropriate ANOVA table for determining if the interaction effect is significant or substantial. As this model is used primarily for the ANOVA table it was given “a” as a prefix. The second model, stored in the $c.lm objects, is the model fit withOUT an intercept and withOUT an interaction term. The results of this model are used to estimate the age and year coefficients. As this model is used primarily for the coefficients it was given “c” as a prefix.

By the nature of the collected data and the linear model one less age or year coefficient can be estimated then exists in the data. Thus, one of the age or year coefficients will be “aliased” and set equal to zero. By default, the first level of the second factor given in the formula is the aliased coefficient. Thus, the aliased coefficient can be changed between age or year coefficients by altering the order the factors are given in the formula. The level of the second factor that is aliased can be changed by changing which level is listed first – see relevel. See the last example below. The aliased coefficient can be seen by submitting the saved wlgm object to the alias function.

The anova function will return the ANOVA table for the $a.lm object in the saved wlgm object if it is the only object submitted to anova (i.e., object2 and object3 are missing). However, if object contains the results from fitting the wlgm to two groups of fish combined and object2 adn object2 contain the results from fitting the wlgm separately to the two groups of fish then anova will return the results of the subsetting procedure outlined in Weisberg (1993).

NEED MORE EXPLANATION IN HERE

Value

The wlgm function returns a list with the following items.

alias A list that has two items – term is which term in the model was aliased and level is which level in that term was aliased.
ageind A numeric that indicates which column in the model frame and the data frame contains the age factor.
yearind A numeric that indicates which column in the model frame and the data frame contains the year factor.
df A data frame that contains the observed increment measurements (first column), age factor (in the column denoted by ageind), year factor (in the column denoted by yearind), the year-class (in yearclass column), and the predicted increment measurement (in the predicted column.
age.coef A matrix that contains the ages (age), coefficient values (Estimate), standard errors (Std. Error), and sample size (n) for all age coefficients.
year.coef A matrix that contains the years (year), coefficient values (Estimate), standard errors (Std. Error), and sample size (n) for all year coefficients.
a.lm The linear model object from the fit of the “anova” model. See details.
c.lm The linear model object from the fit of the “coefficients” model. See details.
summarized A logical indicating whether summarized data was used or not (i.e., raw increments).
crctn A list containing information used to compute the RSS, df, and a correction factor for the SEs when a weighted regression on the summarized increment data is performed. See details.


The alias function does not return any value. It does print which model term and level were aliased.
The anova function returns the anova table for the “anova” model. See details.
The boxcox function does not return any value. It does create a graphic that can be used to determine an approximate confidence interval for the power transformation value, lambda.
The coef function does not return any value. It does print a matrix (or matrices) with the coefficient estimates and associated standard errors.
The confint function returns either a matrix with the confidence interval ranges for the coefficients (if either what="age" or what="year") or a list with two components containing the confidence interval matrices for both the age and year coefficients (if what="both").
The fit.plot function does not return any value. It does create an interaction plot.
The summary function returns a data frame with the sample size (n), average (Avg), and standard deviation (StDev) of observed increment measurements by each unique combination of yearclass, year, and age factors.

Author(s)

Derek H. Ogle, dogle@northland.edu

References

Weisberg, S. Using hard-part increment data to estimate age and environmental effects. Canadian Journal of Fisheries and Aquatic Sciences. 50(6):1229-1237.

See Also

coefplot.WLGM, ycplot.WLGM, fit.plot in NCStats, boxcox in MASS, and lm.

Examples

# Examples using raw increment data
## Data organization -- read, convert, reshape, factor, relevel
data(SMBassWB)
wb1 <- g.convert(SMBassWB,in.pre="anu",type="inc")
wb1$yearclass <- wb1$yearcap-wb1$agecap
wb2 <- subset(wb1,yearclass>1982)
wb2 <- drop.levels(wb2,reorder=FALSE)
wb2r <- g.reshape(wb2,in.pre="inc")
wb2r$year <- wb2r$yearclass+wb2r$age-1
wb2r$fyear <- factor(wb2r$year)
wb2r$fage <- factor(wb2r$age)
levels(wb2r$fyear)
wb2r$fyear <- relevel(wb2r$fyear,"1989")

## model diagnostics
w1 <- wlgm(inc~fage*fyear,data=wb2r,age.first=TRUE)
residual.plot(w1$a.lm,main="")
qqnorm(w1$a.lm$residuals,main="")
hist(w1$a.lm$residuals,main="")

## model results
anova(w1)
ycplot(w1)
coef(w1,what="age")
coef(w1,what="year")
confint(w1,what="age")
confint(w1,what="year")
coefplot(w1,what="age",xlab="Age")
coefplot(w1,what="year",xlab="Growth Year")

## subsetting example
wb2re <- subset(wb2r,gear=="E")
wb2re <- drop.levels(wb2re,reorder=FALSE)
w1e <- wlgm(inc~fage*fyear,data=wb2re)
anova(w1e)
wb2rt <- subset(wb2r,gear=="T")
wb2rt <- drop.levels(wb2rt,reorder=FALSE)
w1t <- wlgm(inc~fage*fyear,data=wb2rt)
anova(w1t)
anova(w1,w1e,w1t)

# show all age coefficients on same plot
coefplot(w1,pts.col="black",con.col="black",ci.col="black",xlim=c(1,7),ylim=c(1,1.8))
par(new=TRUE)
coefplot(w1t,pts.col="blue",con.col="blue",ci.col="blue",xlim=c(1,7),ylim=c(1,1.8))
par(new=TRUE)
coefplot(w1e,pts.col="red",con.col="red",ci.col="red",xlim=c(1,7),ylim=c(1,1.8))
legend(x="topright",legend=c("both gears","trapnets","electrofishing"),col=c("black","blue","red"),pch=19)

# show all year coefficients on same plot
coefplot(w1,what="year",pts.col="black",con.col="black",ci.col="black",xlim=c(1983,1989),ylim=c(-0.55,0.4))
par(new=TRUE)
coefplot(w1t,what="year",pts.col="blue",con.col="blue",ci.col="blue",xlim=c(1983,1989),ylim=c(-0.55,0.4))
par(new=TRUE)
coefplot(w1e,what="year",pts.col="red",con.col="red",ci.col="red",xlim=c(1983,1989),ylim=c(-0.55,0.4))
legend(x="topright",legend=c("both gears","trapnets","electrofishing"),col=c("black","blue","red"),pch=19)

## aliased age rather than year
wb3r <- wb2r
wb3r$fyear <- factor(wb3r$fyear)
wb3r$fage <- factor(wb3r$fage)
wb3r$fage <- relevel(wb3r$fage,"2")
w3 <- wlgm(inc~fyear*fage,data=wb3r,age.first=FALSE)
coefplot(w3,what="age",xlab="Age")
coefplot(w3,what="year",xlab="Growth Year")

# Example with summarized data
## summarize the data
wb4r <- wb2r
names(wb4r)
names(wb4r)[11] <- "value"
wb4sum <- cast(wb4r,fage+fyear~.,Summary)
wb4sum <- wb4sum[,-c(4:5)]
names(wb4sum)[5:10] <- c("StDev","Min","Q1","Median","Q3","Max")
view(wb4sum)

# fit the model
w4 <- wlgm(Mean~fage*fyear,weights=n,sds="StDev",data=wb4sum)
anova(w4)
coef(w4)
coefplot(w4,what="year",xlab="Growth Year")

[Package FSA version 0.0-13 Index]