Introduction to seinfitR"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7,
  fig.height = 5
)

Installation

You can install the development version of seinfitR from GitHub with:

# install.packages("pak")
pak::pak("dslabcena/seinfitR")

Alternatively, if you'd like to install the stable version of seinfitR from CRAN, run:

install.packages("seinfitR")

Overview

The seinfitR package is designed for fitting the Seinhorst equation to experimental data describing the relationship between preplant nematode densities and plant growth. The package provides nonlinear least squares fitting and useful methods for model evaluation and visualization.

Example Analysis

Load Sample Data

We will use the glasshouse dataset included in the package:

library(seinfitR)

data(glasshouse, package = "seinfitR")

Fit the Seinhorst Model

We fit the model using the seinfitR() function, specifying initial parameter values and controlling iteration limits:

model <- seinfitR(
  p_i = "p_i", 
  y = "y", 
  data = glasshouse,
  start = list(m = 6, t = 6),
  control = seinfitR_control(maxiter = 20),
  z_fixed = TRUE
)

Model Result Details

The result of the seinfitR() function returns a list containing several important elements related to the fitted model:

- fit: The fitted model object, which can be further analyzed or extracted.
- summary_seinfitR: A summary of the fitted model, providing details about parameter estimates and statistical significance.
- cov: The covariance matrix of the parameter estimates, if available.
- data: The original dataset used for fitting the model.
- x: The name of the predictor variable (e.g., preplant nematode density).
- y: The name of the response variable (e.g., plant growth).
- z_fixed: A boolean indicating whether the `z` parameter was fixed during model fitting.
If `TRUE`, the function uses the default value for ( z^t ), as described in
Seinhorst, J. W. (1986). Effects of nematode attack on the growth and yield of crop plants. In Cyst nematodes (pp. 191-209). Springer US.

Model Summary

summary(model)

Extract Model Coefficients

coef(model)

coef <- coef(model)

m <- coef[1]
t <- coef[2]
y_max <- coef[3]

cat("m:", m)
cat("t:", t)
cat("y_max", y_max)

Visualizing the Model Fit

The fitted model can be visualized using built-in plotting functions:

plot(model, main = "Seinhorst Model Fit for Glasshouse Data")

For further details, refer to the official GitHub repository.



Try the seinfitR package in your browser

Any scripts or data that you put into this service are public.

seinfitR documentation built on April 11, 2025, 5:54 p.m.