由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - R question
相关主题
突然对直线拟合的R不明白起来了有谁知道crossover design里面作linear mixed model如何计算coefficient of variation (CV)?
Order of Independent Variables in Linear Multiple RegressionRe: reliability coefficient and its CI
问一个关于cox proportional hazard model的基础问题网上看到一道题
请教:关于covariance matrix一个关于multicollinearity的问题
接着问统计问题(有包子答谢)再问multinomial logit
关于R的Simplex的错误信息how to interpret these regression coefficients?
[合集] 关于proc reg 一问, 急~~~~~~~请教比较两个regression coefficient
比较两个regression模型的系数请教一个correlation coefficient的test的问题
相关话题的讨论汇总
话题: fit话题: coeffs话题: res话题: lm
进入Statistics版参与讨论
1 (共1页)
j**p
发帖数: 53
1
would appreciate your help on this on:
I am doing a bunch of lm (~ 100) and wanted to save the results (
coefficients, p value, etc.) nicely to a list
so I have
fit_res = list()
for(n in 1:100)
{
this_fit = lm (....) //I have 5 covariates, so this_fit has 6 coefficients
fit_res$coeffs[n] = this_fit$coefficients
}
however, fit_res$coeffs only contains the first coefficient of each fit, not
the complete set of 6.
thanks!
R*****0
发帖数: 146
2
没有上下文,不过感觉fit_res$coeffs被默认设成了数组,下标[n]只能用于数组(
矩阵,向量)的运算和读写。试试这个:
fit_res <- list(coeffs = vector("list",100))
for (n in 1:100){
this_fit <- lm(...)
fit_res$coeffs[[n]] <- this_fit$coef
}
fit_res$coeffs[[50]][1:6]
以后直接调用双括号下标[[n]]
w****r
发帖数: 28
3
fit_res$coeffs[n] 改成
fit_res$coeffs[[n]]
看看
b********r
发帖数: 764
4
为什么不specify好呢?
fit_res$coeffs<-matrix(nrow=100,ncol=6)
fit_res$coeffs[n,]<-as.vector(this_fit$coefficients)

【在 j**p 的大作中提到】
: would appreciate your help on this on:
: I am doing a bunch of lm (~ 100) and wanted to save the results (
: coefficients, p value, etc.) nicely to a list
: so I have
: fit_res = list()
: for(n in 1:100)
: {
: this_fit = lm (....) //I have 5 covariates, so this_fit has 6 coefficients
: fit_res$coeffs[n] = this_fit$coefficients
: }

c***z
发帖数: 6348
5
try append new rows
instead of filling blanks

【在 j**p 的大作中提到】
: would appreciate your help on this on:
: I am doing a bunch of lm (~ 100) and wanted to save the results (
: coefficients, p value, etc.) nicely to a list
: so I have
: fit_res = list()
: for(n in 1:100)
: {
: this_fit = lm (....) //I have 5 covariates, so this_fit has 6 coefficients
: fit_res$coeffs[n] = this_fit$coefficients
: }

C***i
发帖数: 486
6
fit_res=rbind(fit_res, this_fit$coefficients)
1 (共1页)
进入Statistics版参与讨论
相关主题
请教一个correlation coefficient的test的问题接着问统计问题(有包子答谢)
请问multi variate linear regression 选择risk factor 问题关于R的Simplex的错误信息
GBM in R[合集] 关于proc reg 一问, 急~~~~~~~
两个有关于R的小问题?比较两个regression模型的系数
突然对直线拟合的R不明白起来了有谁知道crossover design里面作linear mixed model如何计算coefficient of variation (CV)?
Order of Independent Variables in Linear Multiple RegressionRe: reliability coefficient and its CI
问一个关于cox proportional hazard model的基础问题网上看到一道题
请教:关于covariance matrix一个关于multicollinearity的问题
相关话题的讨论汇总
话题: fit话题: coeffs话题: res话题: lm