Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer (b) is not *just* about how to program in `R`.

learn more… | top users | synonyms

3
votes
2answers
111 views

MCMC packages in R

Is there an R package for MCMC that can accept my self-defined (log)likelihood function (can be done in MCMCpack) and lets the user define contraints to the ...
0
votes
0answers
20 views

wrong reported Total Sum of Squares in time fixed effects with plm (twoways)

I was sent here from Stackoverflow because this is more a statistics question. I hope I am in the right place now! The summary command of a plm regression with the (factor="twoways") argument reports ...
0
votes
1answer
12 views

How to simulate a binary response variable based on two non-interacting continuous variables [duplicate]

I want to simulate a binary response variable which depends on two normally distributed continuous variables, and I want to have more 1s than 0s in the response variable. I wonder how this can be done ...
-2
votes
0answers
44 views

The R code for showing histogram/plot of conditional distribution of Y|X [closed]

Would you please write the command/code for drawing conditional distribution of Y|X in R programming? I need this code to see if Y and X relationship is skewed or not, and see if I could have ...
0
votes
0answers
6 views

adaptIntegrate in r [migrated]

Does anyone know if adaptIntegrate accepts a vectorized integrand? for e.g. alpha<-c(1,2) f <- function(z){ (z[1]+z[2])*alpha } adaptIntegrate(f,lower=c(1, 3), upper=c(2, 4),tol=0.01) ##does ...
1
vote
0answers
42 views

R - Linear Regression - Control for a variable [migrated]

I have a computer science background & I am trying to teach myself data science by solving the problems available on the internet I have a smallish data set which has 3 variables - race, gender ...
1
vote
0answers
34 views

Find interquartile range of these data

Take these data: 5, 8, 9, 14 R says the interquartile range is 3: ...
0
votes
0answers
31 views

Community stability measure in network analysis using iGraph in R

Does anyone know of a "community stability" measure that is already implemented in iGraph/R?? My approach is to permute the adjacency matrix and compute the association in the cross-frequency table ...
5
votes
1answer
55 views

Oddly large R squared values in meta regression (metafor)

I am using the metafor package in R. I have fit a random effects model with a continuous predictor as follows SIZE=rma(yi=Ds,sei=SE,data=VPPOOLed,mods=~SIZE) ...
0
votes
0answers
20 views

difficulties evaluating if a ordinal multnomial model fitted with polr (in Rstudio) can be used for predicting over new data

I'm getting very different output when i perform a multinomial ordinal model depending on wether I scale or not my data first. Anyone could tell me why? Here are the results with raw data: ...
1
vote
0answers
23 views

What are the tests to measure agreement between two methods of measurement when the unit of measurement is different between the two methods?

Bland-Altman plot measure the agreement between two different methods which measures the same variable. As far as I understand Bland-Altman can measure only if the two methods have the same unit of ...
1
vote
1answer
45 views

What does correlated data mean and how can I visualize it with scatterplot?

I'm playing around with the Abalone dataset in R and following along with this article. The dataset has 8 variables that are taken into account to predict the number of ...
1
vote
0answers
30 views

Optimization in R vs Python, constrained, unconstrained and automatic differentiation?

I am an economics/stat guy who uses quite a bit of optimization (maximum likelihood, simulated maximum likelihood), constrained optimization (mathematical programming w/ equilibrium conditions), ...
0
votes
0answers
24 views

How to do clustering using genetic algorithm?

I am studying how to use genetic algorithm (GA) in clustering analysis on R programming. What I understand now is that we have to determine fitness function in GA. That is, we have to minimize within ...
0
votes
1answer
40 views

How to solve this formula in R for specific days for the whole year? [closed]

I'm a beginner in R. I'd like to calculate the load for 3 water quality parameters in R for specific days for the whole year using the following formula: Using the previous formula, I'd like to ...
0
votes
0answers
10 views

Complex imperfectly crossed three level model - advice on data and analysis sought

I have a question about a multi-level model. I have data from three related sources. Data on about 30 hospitals, at hospital level - things like size, teaching/non-teaching and so on. Data from ...
0
votes
0answers
32 views

Variable Clustering Analysis

I have a data set that consists of 143 variables (~11000 observations), and I wish to do variable clustering to reduce the dimension. I am using hclustvar function ...
0
votes
0answers
5 views

R: subset data frame by logical vector derived from column groups [migrated]

I have a data frame like this: ...
0
votes
0answers
44 views

How to fit Graded Response Model with lme4::glmer

Thanks to Rijmen et al.(2003), we can fit GRM to the data with lme4::glmer. I think Rasch model is straightforward, with ...
0
votes
0answers
51 views

Likelihood of dynamic conditional correlation (DCC) model goes up as model order goes down

The question considers the dynamic conditional correlation (DCC) model by R.Engle (2002) (full reference at the bottom). EDIT: It seems that I misinterpreted ...
0
votes
0answers
25 views

Specify a covariance matrix

I'm trying to replicate the analysis presented on the bottenada.se and described in the ADA repository. Although the demo file is quite detailed, I didn't grasp where those values for the "C0" ...
1
vote
1answer
17 views

rank data in subsets

I have a data asset where one "unique"ID corresponds to multiple cases, shown below. I am looking for a way to create a column ranking each ID by another column but keeping the rank unique for each ...
0
votes
0answers
16 views

Error when using 'mclust' package for mixture model estimation [migrated]

When trying to perform a univariate mixture model estimation, R package mclust produces the following output with an error: ...
-1
votes
1answer
43 views

log-rank test in R

I need to use the survdiff function to statistically compare (using log-rank test) the following survival functions: (1) Male (Sex=1) and Female (Sex=2) (2) ...
0
votes
0answers
26 views

Obtaining variance decomposition table with categorical variables in the model in R [migrated]

I am running a multiple regression with the code: model = lm(Price ~ factor(Make) + Cylinder + Liter + Doors + Cruise + Sound +leather, data=kuiper) I got the ...
2
votes
1answer
52 views

Post hoc test for object of class glmerMod in R?

I am running generalised linear mixed effects models in R using the lme4 package. I am wondering if there are any post-hoc tests available for models built using the glmer function? I know the ...
1
vote
1answer
42 views

Fitting exponential curve to histogram using R

I am trying to fit a curve to a histogram that looks roughly like exponential decay. Since this is roughly similar to exponential decay, I figured a good model was ...
0
votes
0answers
7 views
0
votes
1answer
47 views

Expected Value of Random Variable

I'm trying to find the expected value of a random variable $t_i$ which is the solution of $$\epsilon_i=\mu(t_i-t_{i-1})-\sum^{i-1}_{k=1}\frac{\alpha}{\beta}\left(1-e^{-\beta(t_i-t_k)}\right)$$ ...
1
vote
2answers
62 views

Estimating “Probability” in normal probability plot

I plotted normal probability plot in R using qqnorm and qqline. I want some help on: How to estimate "probability" that a data ...
0
votes
0answers
24 views

How to interpret the output of a multinomial classification model in R package gbm

After running a gradient boosted model with n data points using multinomial regression where the response variable (a factor, as required by the gbm function) has ...
4
votes
4answers
178 views

Predicting time to finish

Out of curiosity, I want to understand how to model this problem. I've been hearing people suggest the use of linear regression but I am not sure how to encode this problem (included my attempt below) ...
0
votes
1answer
34 views

lasso with missing values and categorical variables

I have a dataset with a lot of missing values and mix of continues and categorical variables. I want to use something like group lasso to do features selection. Probably the output is binary 0,1 and ...
1
vote
1answer
55 views

Forecasting at individual versus grouped level

I have monthly usage data (spanning 3 years) for a customer base of around 200K, and I need to generate 1-month ahead forecasts for each of them. There are a couple of exogenous variables that would ...
1
vote
1answer
59 views

Is there a binomial regression model that captures data with fat tails?

Specifically, are there any binomial regression models that use a kernel with heavier tails and higher kurtosis than the standard kernels (logistic/probit/cloglog)? As a function of the linear ...
0
votes
1answer
23 views

How to get Sub-Training and Sub-Test from cross validation in Caret

I am using Caret function I have divided my data into training(75%) and test (25%) sets. Now I am running 10-Fold CV on training data. When i fit following model train_control <- ...
0
votes
0answers
21 views

Differences in AUC calculation in R between pROC and AUC

I was comparing the performance of pROC and AUC libraries when performing auc() calculations on random data: ...
0
votes
0answers
18 views

How to set up the initial data in the nls model

I am struggling with nls model given below. I have a blur idea how to set up the initial values in it. Shall I use "try and error" method or is there any other way to make it more systematic. ...
0
votes
0answers
38 views

Strange GAM results, logistic regression

I am trying to fit a Generalized Partial Linear Model using the package gam in R. I have one continuous predictor EDUC and 3 ...
0
votes
0answers
41 views

Cross validating logistic GAM using CVgam

I have an ecological data set, whereby sediment mud content (%) (i.e. the continuous explanatory variable) is thought to be explaining the spatial distribution (i.e. presence/absence) of various ...
1
vote
1answer
35 views

cross tabulation of two variables with resulting average and SD

I am beginner of R software. I am looking for two variables and result cross tabulated but not in the form of frequencies. Could I get help on how to get result as average and standard deviation ...
0
votes
0answers
25 views

GLMNET in R: Difference between DFMAX and PMAX

In glmnet in R, what is the difference between dfmax and pmax when creating a model with ...
0
votes
0answers
34 views

How to reproduce Google Content Experiments' Probability of Outperforming Original?

I'd like to get a deeper understanding of how Google Content Experiments calculates the Probability of Outperforming Original in practice. The example below gives a case where the reported value ...
3
votes
0answers
45 views

Permutation for large sample sizes (and z-test)

I was trying to do a permutation test on a large amount of temperature observations in R. Approximately 1700 temperature observations (g1) from one place and 2 ...
2
votes
1answer
43 views

Kolmogorov distribution

Is there a package in R for the Kolmogorov distribution which allows me to plot density, distribution, calculates quantiles, etc.? The Kolmogorov distribution arises from $K=\sup|B|$, where $B$ is a ...
3
votes
0answers
52 views

Statistical methods to compare spatial maps

I would like to compare 4 radon flux maps (Bq m-2 s-1) generated using different methods. All of the maps use same projection and have same resolution. I am having trouble finding statistical ...
0
votes
1answer
27 views

Autoclass in R/Python? [closed]

Are there any packages that implement the Autoclass/ Naive Bayes Clustering algorithm in R or Python? Alternatively, what are some other clustering algorithms that can handle both categorical and ...
2
votes
1answer
36 views

fisher.test() and Chi-square bug in R

I'm getting this error when conducting fisher.test() in R: ...
0
votes
2answers
23 views

How to evaluate the fit of our GLM model?

Can anyone tell us how to evaluate the fit of our generalized linear model with a poisson distribution? We can't really tell if the model is a good fit or not. Do you use the deviance to answer this ...