我在Mac上使用pip安装python模块有点新。我设法通过执行sudo python3 -m(模块名称)来安装其他模块,但是我尝试使用的一个模块不会以与其他模块相同的方式安装。在运行python脚本后收到以下消息时,我注意到尚未安装。
County latdecdeg londecdeg State
---------------------------------------------------
Allegheny 40.5254 -80.07213889 PA
Allegheny 40.5526 -80.1159 PA
Allegheny 40.5191 -80.13090556 PA
Allegheny 40.5134 -80.13508889 PA
Allegheny 40.5228 -80.17644722 PA
Allegheny 40.496 -79.939375 PA
Beaver 40.6957 -80.36681667 PA
Berks 40.2485 -76.03885833 PA
Berks 40.2979 -75.89966111 PA
Blair 40.5622 -78.32684722 PA
Blair 40.6001 -78.31262222 PA
所以我假设如果找不到该模块,则未安装。这是我在终端中键入的内容,以尝试安装模块。
set.seed(155656494)
#setting parameter values
n<-500
sdu<-25
beta0<-40
beta1<-12
# Running the simulation again
# create the x variable outside the loop since it’s fixed in
# repeated sampling
x2 <- floor(runif(n,5,16))
# set the number of iterations for your simulation (how many values
# of beta1 will be estimated)
nsim2 <- 10000000
# create a vector to store the estimated values of beta1
vbeta2 <- numeric(nsim2)
# create a loop that produces values of y, regresses y on x, and
# stores the OLS estimate of beta1
for (i in 1:nsim2) {
y2 <- beta0 + beta1*x2 + 0.2*x2 + rnorm(n,mean=0,sd=sdu)
model2 <- lm(y2 ~ x2)
vbeta2[i] <- coef(model2)[[2]]
}
mean(vbeta2)
如果有人可以帮助我安装该模块,我将不胜感激,并感谢您的宝贵时间。