全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 经管代码库
1883 1
2017-08-12
> library(SparseM)

载入程辑包:‘SparseM’

The following object is masked from ‘package:base’:

    backsolve

> library(Matrix)
> library(MatrixModels)
> library(Formula)
> library(quantreg)
> library(rqpd)
> library(plm)
> library(foreign)
> d1 <- read.csv("C:\\Users\\hexiaohui\\Desktop\\panel29.csv")
> summary(d1)
       id          year           city          gdp         
Min.   : 1   Min.   :1995   安徽   : 19   Min.   :  167.8  
1st Qu.: 8   1st Qu.:1999   北京   : 19   1st Qu.: 2078.6  
Median :15   Median :2004   福建   : 19   Median : 4669.1  
Mean   :15   Mean   :2004   甘肃   : 19   Mean   : 8155.4  
3rd Qu.:22   3rd Qu.:2009   广东   : 19   3rd Qu.:10570.5  
Max.   :29   Max.   :2013   广西   : 19   Max.   :62164.0  
                             (Other):437                    
       ec        
Min.   :  32.0  
1st Qu.: 338.1  
Median : 628.8  
Mean   : 877.1  
3rd Qu.:1075.7  
Max.   :4956.6  

> m <- 19
> n <- 29
> s <- as.factor(rep(1:n,rep(m,n)))
> x <- with(d1,cbind(ec))
> ##colnames(as.matrix(x))
> xname <- as.matrix(c("Intercept","EC"))
> num <- dim(x)[2]+1
> y <- d1$gdp
> taus1 <- c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)
> ntaus <- length(taus1)
> tmpmax1 <- floor(1e5+exp(-12.1)*(as.matrix.csr(x)@ia[m+1]-1)^2.35)
> fit <- rqpd(y~x|s,panel(taus=taus1,tauw=c(0.1,0.1,0.1,0.1,0.2,0.1,0.1,0.1,0.1),lambda=1))#control=list(tmpmax=tmpmax1)
> coeff <- summary(fit)
> coef <- coeff$coefficients
> coeffmat = array(NA,dim=c(9,5,num))
> t = 1.96
> for(i in 1:ntaus){
+            for(k in 1:num){
+ coeffmat[i,1,k] = taus1[i]
+ coeffmat[i,2,k] = coef[(num*(i-1)+k),1]
+ coeffmat[i,3,k] = coef[(num*(i-1)+k),2]
+ coeffmat[i,4,k] = coef[(num*(i-1)+k),1]+t*coef[(num*(i-1)+k),2]
+ coeffmat[i,5,k] = coef[(num*(i-1)+k),1]-t*coef[(num*(i-1)+k),2]
+ }
+ }
> dcrec <- plm.data(d1,index=c("id","year"))
> pdcrec <- plm(y~x,effect=c("individual"),model=c("random"),data=dcrec)
> olscf <- summary(pdcrec)$coefficients
> olscoef <- olscf[ ,1]
> olsc <- as.matrix(olscoef)
> up <- olscf[ ,1]+t*olscf[ ,2]
> olsup <- as.matrix(up)
> low <- olscf[ ,1]-t*olscf[ ,2]
> olslow <- as.matrix(low)
我想请问一下:为什么我写完代码之后没有回归结果出来呢?麻烦懂的人指点一下~谢谢~

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2017-8-25 01:45:05
hxh95 发表于 2017-8-12 22:10
&gt; library(SparseM)

载入程辑包:‘SparseM’
大神,你的代码从哪找的,急需你的指教!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群