r语言找不到cochrane函数_R语言 mgcv包 gamm()函数中文帮助文档(中英文对照)

gamm()是R语言mgcv包中的函数,用于拟合广义添加剂混合模型。它通过lme或gammPQL进行拟合,支持随机效应和相关结构。gamm在处理数据时假设主要用来建模残差相关,适用于复杂的模型设定,但速度较慢。本文档介绍了gamm的用法、参数、注意事项及使用示例。
摘要由CSDN通过智能技术生成

gamm(mgcv)

gamm()所属R语言包:mgcv

Generalized Additive Mixed Models

广义添加剂混合模型

译者:生物统计家园网 机器人LoveR

描述----------Description----------

Fits the specified  generalized additive mixed model (GAMM) to data, by a call to lme in the normal errors identity link case, or by  a call to gammPQL (a modification of glmmPQL from the MASS library) otherwise.  In the latter case estimates are only approximately MLEs. The routine is typically  slower than gam, and not quite as numerically robust.

适合指定的广义相加混合的模型(GAMM)的数据,通过呼叫lme在正常错误标识连接的情况,或由一个呼叫到gammPQL(glmmPQL的变形MASS库),否则。在后者的情况下,估计仅约为最大似然估计。该例程是典型的慢于gam,并没有想象中数字强劲。

To use lme4 in place of nlme as the underlying fitting engine,  see gamm4 from package gamm4.

要使用lme4代替nlme:的基本拟合引擎的,看到gamm4从包装gamm4。

Smooths are specified as in a call to gam as part of the fixed  effects model formula, but the wiggly components of the smooth are treated as  random effects. The random effects structures and correlation structures  availabale for lme are used to specify other random effects and  correlations.

平滑处理被指定为在一个呼叫到gam的固定效应模型公式中的一部分,但蠕动的组件的光滑被视为随机效应。随机效应的结构和相关结构availabale lme是用来指定随机效应和相关性。

It is assumed that the random effects and correlation structures are employed  primarily to model residual correlation in the data and that the prime interest is in inference about the terms in the fixed effects model formula including  the smooths. For this reason the routine calculates a posterior covariance  matrix for the coefficients of all the terms in the fixed effects formula,  including the smooths.

据推测,主要采用随机效应和相关结构的数据模型残差相关的主要兴趣是在固定效应模型,包括平滑的公式中的条款推理。由于这个原因,常规计算出的系数固定效应公式中的所有条款,包括平滑后的协方差矩阵。

To use this function effectively it helps to be quite familiar with the use of gam and lme.

要使用此功能,有效地帮助使用gam和lme是很熟悉的。

用法----------Usage----------

gamm(formula,random=NULL,correlation=NULL,family=gaussian(),

data=list(),weights=NULL,subset=NULL,na.action,knots=NULL,

control=list(niterEM=0,optimMethod="L-BFGS-B"),

niterPQL=20,verbosePQL=TRUE,method="ML",...)

参数----------Arguments----------

参数:formula

A GAM formula (see also formula.gam and gam.models). This is like the formula for a glm except that smooth terms (s and te) can be added to the right hand side of the formula. Note that ids for smooths and fixed smoothing parameters are not supported.

一个的GAM公式(formula.gam和gam.models“)。这是像公式的glm除了光滑条款(s和te)可以添加到右手边的公式。需要注意的是ids的平滑和固定的平滑参数不支持。

参数:random

The (optional) random effects structure as specified in a call to  lme: only the list form is allowed, to facilitate  manipulation of the random effects structure within gamm in order to deal with smooth terms. See example below.

(可选的)随机效应的结构中指定一个呼叫到lme:只list形式是允许的,便于操作的随机效应结构内gamm,以便处理与平滑条款。见下面的例子。

参数:correlation

An optional corStruct object  (see corClasses) as used to define correlation  structures in lme. Any grouping factors in the formula for this object are assumed to be nested within any random effect grouping factors, without the need to make this explicit in the formula (this is  slightly different to the behaviour of lme). This  is a GEE approach to correlation in the generalized case. See examples below.

一个可选的corStruct对象(见corClasses)用来定义相关结构lme。此对象的公式中的任何分组因素被假定为是嵌套在任何随机效应分组因素,而不需要使这个明确的在式(这是略有不同的行为lme)。这是GEE在广义的情况下的相关性的方法。见下面的例子。

参数:family

A family as used in a call to glm or gam. The default gaussian

R语言中,mgcv主要用于光滑曲线(smoothing splines)建模,特别是广义线性混合模型(GLMMs)中的空间统计分析。如果你想在`mgcv`中添加空间平滑项,通常会涉及到地理信息系统(GIS)的数据以及`gam`函数。以下是基本步骤: 1. 首先,确保已经安装了`mgcv`和`fields`(用于处理空间数据的)这两个库。如果没有,可以使用`install.packages()`命令安装: ```sh install.packages("mgcv") install.packages("fields") ``` 2. 导入所需库并加载数据。假设你的数据集含空间坐标变量和其他解释变量`x`: ```r library(mgcv) library(fields) data <- read.csv("your_data.csv") # 替换为你的数据文件路径 ``` 3. 将空间坐标变量转换为适合`gam`函数的格式。例如,如果你的空间坐标是经纬度,你可以使用`sp`或`sf`来创建空间数据对象,然后通过`coord_sf()`或其他空间函数将其转换为`gam`能接受的形式: ```r if (requireNamespace("sf", quietly = TRUE)) { data_sp <- st_as_sfc(data$longitude, data$latitude) %>% sf::st_as_sf() } else { # 对于非sf数据,使用 SpatialPointsDataFrame 或其他合适的方式 library(sp) data_sp <- SpatialPointsDataFrame(coords = cbind(data$longitude, data$latitude), data = data[-c("longitude", "latitude")]) } ``` 4. 使用`gam()`函数创建模型,其中`te(some_variable, ~ s(), by = space_variable)`部分就是添加空间平滑项的地方。这里的`s()`代表光滑函数,`some_variable`是你想预测的响应变量,`space_variable`是你的空间坐标变量: ```r model <- gam(response_variable ~ te(x_variable, by = data_sp[, "id"]), family = appropriate_family, data = data) ``` `appropriate_family`取决于你的回归类型,如` gaussian()` for linear regression, `binomial()` for logistic regression等。 5. 可以查看模型摘要和空间影响图,以便理解模型的效果: ```r summary(model) plot(model, se = TRUE) # 可视化空间平滑效果 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值