全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 LATEX论坛
2015-6-22 20:59:40
For the semiparametric regression model: \(Y^{(j)}(x_{in},~t_{in})=t_{in}\beta +g(x_{in})+e^{(j)}(x_{in}),~1\le j\le m,~1\le i \le n\) , where \(x_{in}\in \mathbb {R}^p\) , \(t_{in}\in \mathbb {R}\) are known to be nonrandom, g is an unknown continuous function on a compact set A in \(\mathbb {R}^p\) , \(e^{(j)}(x_{in})\) are \(\tilde{\rho }\) -mixing random variables with mean zero, \(Y^{(j)}(x_{in},t_{in})\) are random variables which are observable at points \(x_{in}\) and \(t_{in}\) . In the paper, we establish the strong consistency, r-th ( \(r>2\) ) mean consistency and complete consistency for estimators \(\beta _{m,n}\) and \(g_{m,n}(x)\) of \(\beta \) and g, respectively. The results obtained in the paper extend the corresponding ones for independent random variables and \(\varphi \) -mixing random variables.
二维码

扫码加我 拉你入群

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

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

2015-6-22 21:04:07
问题饮料“傍名牌”五年未发现 目前涉事企业已被整改,但大量问题饮料未查封 记者日前暗访发现,开封市一家民营饮品企业“傍名牌”生产销售问题饮料长达五年,其“李鬼”饮料销售网络遍布全国。18日记者了解到,目前涉事企业已被整改,但大量问题饮料未被查封,
二维码

扫码加我 拉你入群

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

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

2015-6-22 22:00:33
一对情侣在餐厅吃饭,突然一少妇走过去,直视着对情侣男说“我怀孕了!”
情侣女的一愣,甩手就给了男的一记耳光,
又拉又扯,又哭又闹。
正在小两口不可开交之时,少妇又慢吞吞地说“麻烦你把烟掐了呗!......
二维码

扫码加我 拉你入群

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

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

2015-6-22 22:07:36
计划做的事情一定要把它完成
二维码

扫码加我 拉你入群

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

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

2015-6-22 22:23:50
如果你知道某个捷径,通常意味着别人也知道。而捷径如果被足够多的人知道,将不再成为捷径。(除非你拥有别人所没有的竞争壁垒)
二维码

扫码加我 拉你入群

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

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

2015-6-22 22:29:30
he fetus was found inside the bishop's coffin -- tucked under his feet.
二维码

扫码加我 拉你入群

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

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

2015-6-22 22:30:07
US - UT - Salt Lake City, This position requires a solid knowledge of standard statistical analysis procedures with a minimum of an MS degree in statistics, biostatistics, or a related field, and demonstrated knowledge of at l
二维码

扫码加我 拉你入群

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

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

2015-6-23 06:48:03
出租师傅说刚拉了个活,一大娘带着块展板从一家打印店出来,上面贴着她闺女的照片和学历,月收入。大娘坐车上开说,说闺女30了没对象,她让人戳断了脊梁骨,只有走瞒着子女去广场相亲这条路,但博士不能写,要写大专月薪1W改成4000,这样才有男人敢要她。“
二维码

扫码加我 拉你入群

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

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

2015-6-23 06:48:58
网络上流传已久的那张惊悚“冥婚”图片,原来真相却是台湾一户人家的爷爷辈结婚照,照片现在还挂在客厅当传家宝。先辈结婚照被传成“冥婚”照,家人也是挺郁闷的…
二维码

扫码加我 拉你入群

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

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

2015-6-23 06:49:56
早上,我站在小区门口等班车,一个戴眼镜的小伙走过来问道:“阿姨!我问一下,这里是不是有个金山小区…”我认真的回答道:“你顺着这个道一直向右走,看见交通岗往左走大约两站地,你会发现马路对面有一个公交车车站,然后你坐5路汽车,三站地就到了…”小伙表示感谢后,离开了…没过多久,又过来一个背双肩包的小伙,问道:“美女!这里是不是有个金山小区呀!”我笑着说道:“对!我身后这个小区就是…”
二维码

扫码加我 拉你入群

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

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

2015-6-23 08:54:49
欧元区19国ZF领导人周一晚间在布鲁塞尔召开特别峰会,磋商希腊危机的解决办法。芬兰总理斯图布(Alexander Stubb)此前稍显不悦地表示,这场峰会是浪费飞行时间,因为他不认为同希腊的债务纠纷能取得突破。事实上,欧元集团必须先仔细审核雅典刚刚提出的改革建议。人们因此质疑,各国领导人和ZF首脑是否还有必要飞往布鲁塞尔参加周一晚间的峰会。德国总理默克尔预计各国在这场特别峰会不会作出决议。默克尔周一晚间抵达布鲁塞尔时表示,在没有决议基础的情况下,这场峰会很可能成为一场“磋商会议”,无法作出任何决定。
二维码

扫码加我 拉你入群

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

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

2015-6-23 08:55:33
中国证券网报道,9只上周四发行的新股日前公布申购情况,超级大盘股国泰君安网上网下合计冻结资金2.35万亿元,其中网上冻资规模达1.33万亿,为2009年以来网上申购量最大的新股。而9只新股合计冻结资金达3.8万亿元,再创去年IPO再启以来的最高水平。
二维码

扫码加我 拉你入群

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

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

2015-6-23 08:57:06
The Jupyter Notebook interface allows users to seamlessly mix code, output, and markdown commentary all in the same document.  Sound a bit like R Markdown? The difference is that in a Jupyter Notebook, you execute the code right in the browser and view everything in the same visual view.
二维码

扫码加我 拉你入群

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

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

2015-6-23 08:58:16
Job seekers: please follow the links below to learn more and apply for your job of interest (or visit previous R jobs posts).

Full-Time
Data Scientist (@Nottingham)
Capital One – Posted by S.Kugadasan
Nottingham
England, United Kingdom
19 Jun2015
Full-Time
Lead Data Scientist (@Nottingham)
Capital One – Posted by S.Kugadasan
Nottingham
England, United Kingdom
19 Jun2015
Full-Time
Instructional Technologist (Quantitative Applications) @ReedCollege @Portland
Reed College – Posted by KBott
Portland
Oregon, United States
19 Jun2015
Part-Time
Data Scientist Intern at eBay (@Netanya)
ebay Marketplace Israel – Posted by ebay
Netanya
Center District, Israel
18 Jun2015
Full-Time
Statistician Intermediate at Rice University (@Houston)
Children’s Environmental Health Initiative – Posted bykafi@umich.edu
Houston
Texas, United States
18 Jun2015
Full-Time
Data Scientist (@TelAviv)
ubimo – Posted by Tal
Tel Aviv-Yafo
Tel Aviv District, Israel
18 Jun2015
Full-Time
Data Scientist/Statistician (@KfarSaba)
Haimke
Kefar Sava
Center District, Israel
17 Jun2015
Full-Time
R Programmer / Data Analyst (@SanDiego)
University of California San Diego Dept. of Radiation Medicine – Posted by lmell
San Diego
California, United States
16 Jun2015
Full-Time
Data Scientist (@Prague)
CGI – Posted by CGI
Prague
Hlavní město Praha, Czech Republic
16 Jun2015
Full-Time
R Programmer (@Connecticut)
Paul Dai – Real Staffing – Posted by Paul Dai
Ridgefield
Connecticut, United States
11 Jun2015
Full-Time
Data Scientist (@Holon)
Yoni Schamroth / Perion Networks – Posted by Yoni Schamroth
Holon
Center District, Israel
11 Jun2015
Full-Time
Quantitative Research Assistant for predicting the effects of public policy
American Enterprise Institute – Posted by clairegaut
Anywhere
10 Jun2015
二维码

扫码加我 拉你入群

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

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

2015-6-23 08:59:10
I restarted at working my way through the PROC MCMC examples. The SAS manual describes this example: Consider the data set from Bacon and Watts (1971), where $y_ i$ is the logarithm of the height of the stagnant surface layer and the covariate $x_ i$ is the logarithm of the flow rate of water.
It is a simple example. It provided no problems at all for STAN and Jags. For LaplacesDemon on the other hand I had some problems. It took me quite some effort to obtain samples which seemed to be behaving. I did not try to do this in MCMCpack, but noted that the function MCMCregressChange() uses a slightly different model. The section below shows first the results, at the bottom the code is given.

Previous post in the series PROC MCMC examples programmed in R were: example 61.1: sampling from a known density, example 61.2: Box Cox transformation, example 61.5: Poisson regression, example 61.6: Non-Linear Poisson Regression, example 61.7: Logistic Regression Random-Effects Model, and example 61.8: Nonlinear Poisson Regression Multilevel Random-Effects Model
Data

Data are read as below.
observed <-
‘1.12  -1.39   1.12  -1.39   0.99  -1.08   1.03  -1.08
0.92  -0.94   0.90  -0.80   0.81  -0.63   0.83  -0.63
0.65  -0.25   0.67  -0.25   0.60  -0.12   0.59  -0.12
0.51   0.01   0.44   0.11   0.43   0.11   0.43   0.11
0.33   0.25   0.30   0.25   0.25   0.34   0.24   0.34
0.13   0.44  -0.01   0.59  -0.13   0.70  -0.14   0.70
-0.30   0.85  -0.33   0.85  -0.46   0.99  -0.43   0.99
-0.65   1.19′
observed <- scan(text=gsub(‘[[:space:]]+’,’ ‘,observed),
    what=list(y=double(),x=double()),
    sep=’ ‘)
stagnant <- as.data.frame(observed)
LaplacesDemon

I have been playing around with LaplacesDemon. There is actually a function
LaplacesDemon.hpc which can use multiple cores. However, on my computer it seems more efficient just to use mclapply() from the parallel package and give the result class LaplacesDemon.hpc . Having said that, I had again quite some trouble to get LaplacesDemon to work well. In the end I used a combination of two calls to LaplacesDemon. The plot below shows selected samples after the first run. Not good enough, but that I do like this way of displaying the results of chains. It should be added that the labels looked correct with all parameters. However, that gave to much output for this blog. In addition, after the second call the results looked acceptable.



Call:
LaplacesDemon(Model = Model, Data = MyData, Initial.Values = apply(cc1$Posterior1,
    2, median), Covar = var(cc1$Posterior1), Iterations = 1e+05,
    Algorithm = “RWM”)

Acceptance Rate: 0.2408
Algorithm: Random-Walk Metropolis
Covariance Matrix: (NOT SHOWN HERE; diagonal shown instead)
       alpha        beta1        beta2           cp           s2
4.920676e-04 2.199525e-04 3.753738e-04 8.680339e-04 6.122862e-08

Covariance (Diagonal) History: (NOT SHOWN HERE)
Deviance Information Criterion (DIC):
          All Stationary
Dbar -144.660   -144.660
pD      7.174      7.174
DIC  -137.486   -137.486
Initial Values:
        alpha         beta1         beta2            cp            s2
0.5467048515 -0.4100040451 -1.0194586232  0.0166405998  0.0004800931

Iterations: 4e+05
Log(Marginal Likelihood): 56.92606
Minutes of run-time: 1.32
Model: (NOT SHOWN HERE)
Monitor: (NOT SHOWN HERE)
Parameters (Number of): 5
Posterior1: (NOT SHOWN HERE)
Posterior2: (NOT SHOWN HERE)
Recommended Burn-In of Thinned Samples: 0
Recommended Burn-In of Un-thinned Samples: 0
Recommended Thinning: 5
Specs: (NOT SHOWN HERE)
Status is displayed every 100 iterations
Summary1: (SHOWN BELOW)
Summary2: (SHOWN BELOW)
Thinned Samples: 40000
Thinning: 1

Summary of All Samples
                  Mean           SD         MCSE      ESS            LB
alpha     5.348239e-01 0.0244216567 2.999100e-04 11442.06  4.895229e-01
beta1    -4.196180e-01 0.0142422533 1.661658e-04 12726.60 -4.469688e-01
beta2    -1.013882e+00 0.0164892337 1.681833e-04 15191.59 -1.046349e+00
cp        2.855852e-02 0.0308177765 3.649332e-04 11945.66 -3.406306e-02
s2        4.472644e-04 0.0001429674 1.383748e-06 16571.94  2.474185e-04
Deviance -1.446602e+02 3.7879060637 4.940488e-02 10134.91 -1.496950e+02
LP        4.636511e+01 1.8939530321 2.470244e-02 10134.91  4.164313e+01
                Median            UB
alpha       0.53339024  5.842152e-01
beta1      -0.41996859 -3.903572e-01
beta2      -1.01387256 -9.815650e-01
cp          0.03110570  8.398674e-02
s2          0.00042101  8.006666e-04
Deviance -145.46896682 -1.352162e+02
LP         46.76949458  4.888251e+01

Summary of Stationary Samples
                  Mean           SD         MCSE      ESS            LB
alpha     5.348239e-01 0.0244216567 2.999100e-04 11442.06  4.895229e-01
beta1    -4.196180e-01 0.0142422533 1.661658e-04 12726.60 -4.469688e-01
beta2    -1.013882e+00 0.0164892337 1.681833e-04 15191.59 -1.046349e+00
cp        2.855852e-02 0.0308177765 3.649332e-04 11945.66 -3.406306e-02
s2        4.472644e-04 0.0001429674 1.383748e-06 16571.94  2.474185e-04
Deviance -1.446602e+02 3.7879060637 4.940488e-02 10134.91 -1.496950e+02
LP        4.636511e+01 1.8939530321 2.470244e-02 10134.91  4.164313e+01
                Median            UB
alpha       0.53339024  5.842152e-01
beta1      -0.41996859 -3.903572e-01
beta2      -1.01387256 -9.815650e-01
cp          0.03110570  8.398674e-02
s2          0.00042101  8.006666e-04
Deviance -145.46896682 -1.352162e+02
LP         46.76949458  4.888251e+01
STAN

Stan did not give much problems for this analysis.
Inference for Stan model: smodel.
4 chains, each with iter=2000; warmup=1000; thin=1;
post-warmup draws per chain=1000, total post-warmup draws=4000.

         mean se_mean   sd  2.5%   25%   50%   75% 97.5% n_eff Rhat
Beta[1] -0.42    0.00 0.01 -0.45 -0.43 -0.42 -0.41 -0.39  1017 1.00
Beta[2] -1.01    0.00 0.02 -1.05 -1.02 -1.01 -1.00 -0.98  1032 1.00
Alpha    0.54    0.00 0.03  0.49  0.52  0.53  0.55  0.59   680 1.00
s2       0.00    0.00 0.00  0.00  0.00  0.00  0.00  0.00  1361 1.00
cp       0.03    0.00 0.03 -0.04  0.00  0.03  0.05  0.09   636 1.00
lp__    90.63    0.06 1.78 86.17 89.71 91.00 91.91 93.03   935 1.01

Samples were drawn using NUTS(diag_e) at Fri Jun 19 21:17:54 2015.
For each parameter, n_eff is a crude measure of effective sample size,
and Rhat is the potential scale reduction factor on split chains (at
convergence, Rhat=1).
JAGS

Again no problems for Jags.
Inference for Bugs model at “/tmp/Rtmpy4a6C5/modeld4f6e9c9055.txt”, fit using jags,
4 chains, each with 10000 iterations (first 5000 discarded), n.thin = 5
n.sims = 4000 iterations saved
          mu.vect sd.vect     2.5%      25%      50%      75%    97.5%  Rhat
alpha       0.534   0.027    0.479    0.518    0.533    0.552    0.586 1.040
beta[1]    -0.420   0.015   -0.450   -0.429   -0.420   -0.410   -0.389 1.013
beta[2]    -1.014   0.017   -1.049   -1.024   -1.014   -1.003   -0.980 1.023
cp          0.029   0.035   -0.038    0.006    0.032    0.051    0.100 1.037
s2          0.000   0.000    0.000    0.000    0.000    0.001    0.001 1.004
deviance -144.501   3.986 -149.634 -147.378 -145.432 -142.584 -134.378 1.021
         n.eff
alpha      160
beta[1]    380
beta[2]    290
cp         160
s2         710
deviance   290

For each parameter, n.eff is a crude measure of effective sample size,
and Rhat is the potential scale reduction factor (at convergence, Rhat=1).

DIC info (using the rule, pD = var(deviance)/2)
pD = 7.9 and DIC = -136.6
DIC is an estimate of expected predictive error (lower deviance is better).
CODE used

# http://support.sas.com/documentation/cdl/en/statug/67523/HTML/default/viewer.htm#statug_mcmc_examples18.htm
# Example 61.12 Change Point Models
##############
#Data                                                   
##############
observed <-
‘1.12  -1.39   1.12  -1.39   0.99  -1.08   1.03  -1.08
0.92  -0.94   0.90  -0.80   0.81  -0.63   0.83  -0.63
0.65  -0.25   0.67  -0.25   0.60  -0.12   0.59  -0.12
0.51   0.01   0.44   0.11   0.43   0.11   0.43   0.11
0.33   0.25   0.30   0.25   0.25   0.34   0.24   0.34
0.13   0.44  -0.01   0.59  -0.13   0.70  -0.14   0.70
-0.30   0.85  -0.33   0.85  -0.46   0.99  -0.43   0.99
-0.65   1.19′
observed <- scan(text=gsub(‘[[:space:]]+’,’ ‘,observed),
    what=list(y=double(),x=double()),
    sep=’ ‘)
stagnant <- as.data.frame(observed)
#plot(y~x,data=stagnant)
##############
#LaplacesDemon                                                   
##############
library(‘LaplacesDemon’)
library(parallel)

mon.names <- “LP”
parm.names <- c(‘alpha’,paste(‘beta’,1:2,sep=”),’cp’,’s2′)

PGF <- function(Data) {
  x <-c(rnorm(5,0,1))
  x[4] <- runif(1,-1.3,1.1)
  x[5] <- runif(1,0,2)
  x
}
MyData <- list(mon.names=mon.names,
    parm.names=parm.names,
    PGF=PGF,
    x=stagnant$x,
    y=stagnant$y)
#N<-1
Model <- function(parm, Data)
{
  alpha=parm[1]
  beta=parm[2:3]
  cp=parm[4]
  s2=parm[5]
  yhat <- alpha+(Data$x-cp)*beta[1+(Data$x>=cp)]
  LL <- sum(dnorm(Data$y,yhat,sd=sqrt(s2),log=TRUE))
  prior <- sum(dnorm(parm[1:3],0,1e3,log=TRUE))+
      dunif(cp,-1.3,1.1,log=TRUE)+
      dunif(s2,0,5,log=TRUE)
  LP=LL+prior
  Modelout <- list(LP=LP, Dev=-2*LL, Monitor=LP,
      yhat=yhat,
      parm=parm)
  return(Modelout)
}
Fit1 <- mclapply(1:4,function(i)
      LaplacesDemon(Model,
    Data=MyData,
    Iterations=100000,
    Algorithm=’RWM’,
    Covar=c(rep(.01,4),.00001),
    Initial.Values = c(.5,-.4,-1,.05,.001)) #Initial.Values  
)
class(Fit1) <- ‘demonoid.hpc’
plot(Fit1,Data=MyData,Parms=c(‘alpha’))
cc1 <- Combine(Fit1,MyData)
#
Fit2 <- mclapply(1:4,function(i)
      LaplacesDemon(Model,
          Data=MyData,
          Iterations=100000,
          Algorithm=’RWM’,
          Covar=var(cc1$Posterior1),
          Initial.Values = apply(cc1$Posterior1,2,median)) #Initial.Values  
)
class(Fit2) <- ‘demonoid.hpc’
#plot(Fit2,Data=MyData,Parms=c(‘alpha’))
cc2 <- Combine(Fit2,MyData)
cc2
##############
#STAN                                                   
##############
stanData <- list(
    N=nrow(stagnant),
    x=stagnant$x,
    y=stagnant$y)

library(rstan)
smodel <- ‘
    data {
    int <lower=1> N;
    vector[N] x;
    vector[N] y;
    }
    parameters {
    real Beta[2];
    real Alpha;
    real <lower=0> s2;
    real <lower=-1.3,upper=1.1> cp;
    }
    transformed parameters {
    vector[N] yhat;
    for (i in 1:N)
       yhat[i] <- Alpha+(x[i]-cp)*Beta[1+(x[i]>cp)];
    }
    model {
    y ~ normal(yhat,sqrt(s2));
    s2 ~ uniform(0,1e3);
    cp ~ uniform(-1.3,1.1);
    Alpha ~ normal(0,1000);
    Beta ~ normal(0,1000);
    }
    ‘
fstan <- stan(model_code = smodel,
    data = stanData,
    pars=c(‘Beta’,’Alpha’,’s2′,’cp’))
fstan
##############
#Jags                                                   
##############
library(R2jags)jagsdata <- list(
    N=nrow(stagnant),
    x=stagnant$x,
    y=stagnant$y)

jagsm <- function() {
  for(i in 1:N) {
    yhat[i] <- alpha+(x[i]-cp)*beta[1+(x[i]>cp)]
    y[i] ~ dnorm(yhat[i],tau)
  }
  tau <- 1/s2
  s2 ~  dunif(0,1e3)
  cp ~ dunif(-1.3,1.1)
  alpha ~ dnorm(0,0.001)
  beta[1] ~ dnorm(0,0.001)
  beta[2] ~ dnorm(0,0.001)
}
params <- c(‘alpha’,’beta’,’s2′,’cp’)
myj <-jags(model=jagsm,
    data = jagsdata,
    n.chains=4,
    n.iter=10000,
    parameters=params,
)
myj

To leave a comment for the author, please follow the link and comment on his blog: Wiekvoet.
R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...
二维码

扫码加我 拉你入群

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

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

2015-6-23 08:59:48
(This article was first published on FishyOperations, and kindly contributed to R-bloggers)
dimple is a simple-to-use charting API powered by D3.js.

Making use of the nice htmlwidgets package it only took a minimum amount of coding to make the dimple library available from R.

You can find the dimple R package at github.com/Bart6114/dimple and some documentation and examples at: bart6114.github.io/dimple (can take a while to load). Using the package you can create static javascript-based graphs, but you can also use dimple charts in Shiny applications.
二维码

扫码加我 拉你入群

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

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

2015-6-23 09:01:54
The subtitle of this post can be “How to plot multiple elements on interactive web maps in R“.
In this experiment I will show how to include multiple elements in interactive maps created using both plotGoogleMaps and leafletR. To complete the work presented here you would need the following packages: sp, raster, plotGoogleMaps and leafletR.

I am going to use data from the OpenStreet maps, which can be downloaded for free from this website: weogeo.com
In particular I downloaded the shapefile with the stores, the one with the tourist attractions and the polyline shapefile with all the roads in London. I will assume that you want to spend a day or two walking around London, and for this you would need the location of some hotels and the locations of all the Greggs in the area, for lunch. You need to create a web map that you can take with you when you walk around the city with all these customized elements, that’s how you create it.

Once you have downloaded the shapefile from weogeo.com you can open them and assign the correct projection with the following code:

stores <- shapefile("weogeo_j117529/data/shop_point.shp")
projection(stores)=CRS("+init=epsg:3857")

roads <- shapefile("weogeo_j117529/data/route_line.shp")
projection(roads)=CRS("+init=epsg:3857")

tourism <- shapefile("weogeo_j117529/data/tourism_point.shp")
projection(tourism)=CRS("+init=epsg:3857")
To extract only the data we would need to the map we can use these lines:

Greggs <- stores[stores$NAME %in% c("Gregg's","greggs","Greggs"),]

Hotel <- tourism[tourism$TOURISM=="hotel",]
Hotel <- Hotel[sample(1:nrow(Hotel),10),]


Footpaths <- roads[roads$ROUTE=="foot",]
plotGoogleMaps
I created three objects, two are points (Greggs and Hotel) and the last is of class SpatialLinesDataFrame. We already saw how to plot Spatial objects with plotGoogleMaps, here the only difference is that we need to create several maps and then link them together.
Let’s take a look at the following code:

Greggs.google <- plotGoogleMaps(Greggs,iconMarker=rep("http://local-insiders.com/wp-content/themes/localinsiders/includes/img/tag_icon_food.png",nrow(Greggs)),mapTypeId="ROADMAP",add=T,flat=T,legend=F,layerName="Gregg's",fitBounds=F,zoom=13)
Hotel.google <- plotGoogleMaps(Hotel,iconMarker=rep("http://www.linguistics.ucsb.edu/projects/weal/images/hotel.png",nrow(Hotel)),mapTypeId="ROADMAP",add=T,flat=T,legend=F,layerName="Hotels",previousMap=Greggs.google)

plotGoogleMaps(Footpaths,col="dark green",mapTypeId="ROADMAP",filename="Multiple_Objects_GoogleMaps.html",legend=F,previousMap=Hotel.google,layerName="Footpaths",strokeWeight=2)
As you can see I first create two objects using the same function and then I call again the same function to draw and save the map. I can link the three maps together using the option add=T and previousMap.
We need to be careful here though, because the use of the option add is different from the standard plot function. In plot I can call the first and then if I want to add a second I call again the function with the option add=T. Here this option needs to go in the first and second calls, not in the last. Basically in this case we are saying to R not to close the plot because later on we are going to add elements to it. In the last line we do not put add=T, thus saying to R to go ahead and close the plot.

Another important option is previousMap, which is used starting from the second plot to link the various elements. This option is used referencing the previous object, meaning that I reference the map in Hotel.google to the map map to Greggs.google, while in the last call I reference it to the previous Hotel.google, not the very first.

The zoom level, if you want to set it, goes only in the first plot.

Another thing I changed compared to the last example is the addition of custom icons to the plot, using the option iconMarker. This takes a vector of icons, not just one, with the same length of the SpatialObject to be plotted. That is why I use the function rep, to create a vector with the same URL repeated for a number of times equal to the length of the object.
The icon can be whatever image you like. You can find a collection of free icons from this website: http://kml4earth.appspot.com/icons.html

The result is the map below, available here: Multiple_Objects_GoogleMaps.html


leafletR
We can do the same thing using leafletR. We first need to create GeoJSON files for each element of the map using the following lines:

Greggs.geojson <- toGeoJSON(Greggs)
Hotel.geojson <- toGeoJSON(Hotel)
Footpaths.geojson <- toGeoJSON(Footpaths)
Now we need to set the style for each element. For this task we are going to use the function styleSingle, which basically defines a single style for all the elements of the GeoJSON. This differ from the map in a previous post in which we used the function styleGrad to create graduated colors depending of certain features of the dataset.
We can change the icons of the elements in leafletR using the following code:

Greggs.style <- styleSingle(marker=c("fast-food", "red", "s"))
Hotel.style <- styleSingle(marker=c("lodging", "blue", "s"))
Footpaths.style <- styleSingle(col="darkred",lwd=4)
As you can see we have the option marker that takes a vector with the name of the icon, its color and its size (between “s” for small, “m” for medium and “l” for large). The names of the icons can be found here: https://www.mapbox.com/maki/, where you have a series of icons and if you hover the mouse over them you would see some info, among which there is the name to use here, as the very last name. The style of the lines is set using the two options col and lwd, for line width.

Then we can simply use the function leaflet to set the various elements and styles of the map:

leaflet(c(Greggs.geojson,Hotel.geojson,Footpaths.geojson),style=list(Greggs.style,Hotel.style,Footpaths.style),popup=list(c("NAME"),c("NAME"),c("OPERATOR")),base.map="osm")
二维码

扫码加我 拉你入群

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

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

2015-6-23 14:35:49
The sample covariance matrix, which is well known to be highly nonrobust, plays a central role in many classical multivariate statistical methods. A popular way of making such multivariate methods more robust is to replace the sample covariance matrix with some robust scatter matrix. The aim of this paper is to point out that multivariate methods often require that certain properties of the covariance matrix hold also for the robust scatter matrix in order for the corresponding robust plug-in method to be a valid approach, but that not all scatter matrices possess the desired properties. Plug-in methods for independent components analysis, observational regression and graphical modelling are considered in more detail. For each case, it is shown that replacing the sample covariance matrix with a symmetrized robust scatter matrix yields a valid robust multivariate procedure.
二维码

扫码加我 拉你入群

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

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

2015-6-23 15:33:36

二维码

扫码加我 拉你入群

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

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

2015-6-23 16:48:49

二维码

扫码加我 拉你入群

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

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

2015-6-23 19:07:05
俄罗斯联邦副总理德沃尔科维奇日前在圣彼得堡国际经济论坛表示,俄罗斯不会使用转基因技术(GMOs)来提高农业生产力。德沃尔科维奇说:“俄罗斯已经选择了一条不同的道路,我们不会使用这些技术。这一决定将使俄罗斯的相关产品成为‘世界上最干净的’。”此前,俄农业部长费奥多罗夫也认为,俄罗斯必须保持是个非转基因国家,因为ZF不会“毒害他们的公民。”
二维码

扫码加我 拉你入群

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

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

2015-6-23 19:11:09
看到有人在焦急预测北京和其他省市高考分数线,要我说就不必了,帝都这里试卷都是不一样的,简单很多,目的就是为了分数线能高一些,和别的省市看起来差距不那么大。要是统一试卷,帝都分数线要是不比外地低个百八十分,这里的孩子很多是上不了大学的。对那些还在说高考公平的人我就只好呵呵了……
二维码

扫码加我 拉你入群

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

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

2015-6-23 19:12:33
莱特兄弟从1896年就开始研究飞机。他们一边开自行车店赚钱,一边还要积累航空知识,观察老鹰飞行,反复设计图纸,经过三年多日日夜夜的准备,在1900年10月莱特兄弟制成了依靠风力做动力的滑翔机。莱特兄弟发现,一路上,他的速度确实比其他车辆快了些,但并没有出现狂奔的现象。
二维码

扫码加我 拉你入群

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

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

2015-6-23 19:35:13
我们不经不觉进入了 4K 电视的时代,可是其萤幕技术大多都是使用 LCD,追于追求高对比度使用者不甚合适。今天 LG 就在香港推出了少数用上 4K OLED 面板的曲面电视系列 EG9600(上图)/ EG9700,让电视画面细致之余,色彩显示更为丰富。另外,同场更有一台有着 5K IPS 面板的 105 吋 21:9 曲面电视,显示 LG 在打造电视的造诣。
二维码

扫码加我 拉你入群

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

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

2015-6-23 19:36:08
Lamb genetically modified with jellyfish protein found its way from a research lab to a butcher in Paris – and was bought by an unknown person

French authorities are looking into how a lamb genetically modified with jellyfish protein was sold as meat to an unknown customer, a judicial source told AFP on Tuesday.

The jellyfish-lamb, called “Rubis”, was sent to an abattoir from the National Institute for Agricultural Research in Paris late last year and somehow ended up on a butcher’s slab.
二维码

扫码加我 拉你入群

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

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

2015-6-23 19:42:39
• Reports had stated Gerhard Berger was set to replace Briton
• ‘We know we have problems but we just have to work through them’
Red Bull principal Christian Horner has shrugged off speculation about his future and said he is determined to stay on to help the troubled Formula One team resolve their problems.

The Times newspaper reported on Tuesday that one of Horner’s rival principals had called him on Sunday morning, before the Austrian Grand Prix, to commiserate about his supposed departure.
二维码

扫码加我 拉你入群

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

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

2015-6-23 19:46:26
A whole baked fish for a summer’s day

Wash and trim four slim spring carrots and either slice them in half lengthways or into short cork-sized lengths. Slice a head of fennel in half from stem to root, then slice each half thinly.
二维码

扫码加我 拉你入群

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

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

2015-6-23 19:48:53
French capital last staged the event in 1924
• Boston, Hamburg and Rome also in frame
Paris has officially announced its bid to host the 2024 Olympic Games and bring the global sports event back to the French capital for the first time in a century.

The announcement in Paris, which narrowly lost out to London in the battle to host the 2012 Olympics, marks the start of a two-year selection process where the city will go head to head with cities such as Rome for the right to play host.
二维码

扫码加我 拉你入群

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

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

2015-6-23 23:52:11
固态硬盘(SSD)仍然比机械硬盘贵,但它的价格正沿着一条下坡路快速下跌。1TB的SSD价格有望逼近300美元,到2016年底SSD和机械硬盘的价格有可能相差无几。除了价格,SSD在容量上正快速赶超,到2018年30TB的SSD都有可能面世。SSD在性能上远胜于机械硬盘,当机械硬盘不再具有性价比的时候,SSD的过渡将会变得像海啸一样不可抵挡。
二维码

扫码加我 拉你入群

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

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

2015-6-24 07:13:54
现时面容辨识技术已经成为家常便饭,但如果不靠面容也能辨别出一个人的身份之技术,大家觉得如何?New Scientist 的报道指 Facebook 旗下的人工智能实验室,已经开发出一款能不靠面容也能找出人物身份的算法。这款算法可以依据相中人的发型、姿势、衣着和身形去判断他 / 她的身份,所以有关人物的面容被遮掩了仍是可以被认出。该实验室的负责人 Yann LeCun 指出人类已经擅于这样的技巧,而他们也期望开发出这样的技术,并表示每个人都有一些特点(例如 Mark Zuckerberg 常常穿灰...
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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