R无法识别变量,不确定原因

时间:2018-11-27 14:59:36

标签: r variables bayesian

我目前正在使用R studio,并为熟悉它的人下载了'brms'软件包。我想创建一个加载数据集的代码,对它进行泊松转换,然后将转换编码为另一个变量:

`install.packages("brms")
library(brms)
#In this example, we have a data set which includes data for fishing,
#like number of fish caught, whether bait was used, etc.
#We will bit this using something called a 'zero limit possion' model'.
zinb <- read.csv("http://stats.idre.ucla.edu/stat/data/fish.csv") #data set
zinb$camper <- factor(zinb$camper, labels = c("no", "yes")) #adding whether camper was there
head(zinb)
is.data.frame(zinb)
summary(zinb)
#below, we fit our zinb data set into that zero limit possion model, and
#our predictors will be number of persons, whether there was a child,
#and if the group consisted of campers. 
fit_zinb1=brm(data=zinb, count ~persons + child + camper,
             family = zero_inflated_poisson("log")) #specify the data, and the family

#see what it looks like
summary(fit_zinb1)

但是,R无法识别我的新变量“ fit_zinb1”。关于为什么可能会这样的想法?

非常感谢您!

1 个答案:

答案 0 :(得分:1)

感谢您的提问。您的代码运行良好,并提供以下输出。

这可能意味着您的系统未正确设置为运行SELECT dept_id, last_name, salary, LEAD (salary,1) OVER (ORDER BY salary) AS next_highest_salary FROM employees; 。 您是否尝试过在library(brms)中运行简单的模型?例如,这里有八所学校的模型:https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

它可能不会运行,并且可能会让您更好地了解运行这些模型的设置中缺少的内容。

library(rstan)
相关问题