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

0
votes
0answers
22 views

Calculating probability of full house and royal straight in R poker simulation

Given a poker simulation in R using vectors for the denomination and class of playing card in a loop, how would one go about identifying a given hand containing a full house or a royal straight. I'm ...
0
votes
0answers
6 views

Are there any packages to calculate accuracy, precision, recall and f-measure achieved by a KNN-classifier in R language? [on hold]

I have been trying to find packages to find accuracy,recall, precision etc performance metrics for the KNN-classifier. The closest I could find was caret but it says the object in its parameters has ...
-1
votes
0answers
38 views

Calculate the mean and variance of two random variables from their density functions

How do you calculate the mean and variance of two random variables X~F(m = 3, n = 6) and Y~F(m = 8, n = 6) from their density functions using R?
0
votes
0answers
9 views

Rescaling a variable in R [migrated]

I have a variable named Esteem that is in a scale 1:7. I would like to rescale it to 1:100. I understand that the R program scales can do so, however I am having problems with the syntax. Could ...
0
votes
1answer
10 views

Smoothing parameter for spline curve with duplicate points

I have body mass and age data for a population of individuals. I want to fit a cubic smoothing spline curve to the data. I'm using smooth.spline in R, which warns against using cross-validation to ...
0
votes
0answers
16 views

Analysis of mixed variables

I'm currently working some data collected as a part of an interview survey. I have a response variable in ordinal form, which mostly looks into people's perceptions of an animal, and a range of ...
0
votes
0answers
30 views

how to get theoretical center of distribution and theoretical variance of the distribution

Here for 1000 simulations and 40 samples for each, here is random exponential distributor using replicate function ...
0
votes
0answers
12 views

Cluster robust standard errors for the Hausman-Taylor estimator

Suppose I compute the Hausman-Taylor estimator using the plm command with the option: model= "ht". Using the result I like to obtain a robust variance-covariance matrix to make inference fully robust. ...
1
vote
1answer
57 views

Multiple regression in R with different data types of predictors

My goal is to investigate a dependent variable which is metric (time in hours). The independent variables include 3 metric, 2 binary (factors), and one factor variable, which consists of 11 districts ...
0
votes
1answer
16 views

plotting “log relative hazard” against continuous covariate: what are knots when using cph

I try to get into in Cox Regression and read the example chapter from Steyerberg's book. Afterwards I tried to plot log relative hazards against continuous variables using the rms package: ...
0
votes
0answers
10 views

Log-rank / Cox analysis with very unequal sized groups: alternative calculations of p-value?

I would like to set up a series of tests on the difference in survival between two very unequal sized groups. Generally either log-rank (using the R survdiff function) or a cox regression (R coxph) ...
0
votes
1answer
14 views

Multiple regression in R with different data types of predictors

My goal is to investigate a dependent variable which is metric (time in hours). The independent variables include 3 metric, 2 binary (factors), and one factor variable, which consists of 11 districts ...
0
votes
0answers
8 views

Testing variability in chromosome numbers at different taxnonomic levels?

Suppose I have a data set listing the chromosome count of a large number of species. Each species, in addition to chromosome count, have data on their Phylum, Order, and Family. I would like to know ...
0
votes
0answers
19 views

Code for type=“h” in ggplot2 [migrated]

This may sound really simple but I'm trying to find the equivalent code to plot(x,y, type="h") as a qplot code. I already have: ...
0
votes
0answers
25 views

Stock Closing price forecasting using ARIMA Model in R ( Entry level R programmer and Statistics learner)

I am an entry level R programmer and trying to learn statistics. i have downloaded the daily stock Adjusted Close price of one stock from sep 2011 to till date. As per my study plan, i have plotted ...
1
vote
0answers
16 views

How can you cluster a set of functions with unknown functional forms?

Say you've $N$ functions $f_N(x)$ defined on a regular grid $x$. You don't know the form of $f(x)$, you've only got several realizations of it. The different functions are related to each other ...
0
votes
1answer
21 views

Estimating Standard Errors for Markov Transition Probability with Multiple Observations (in R)

I was trying to estimate a Markov transition table from paired transition data, which look something like this: ...
0
votes
0answers
14 views

R, TukeyHSD or HSD.test into boxplot graph [on hold]

I am trying to make boxplots of TukeyHSD data or HSD.test data Currently my code looks like this: ...
1
vote
0answers
16 views

Performing a linear regression on small dataset and trouble with modeling small predictor values

I have a dataset. y: the dependent variable (representing a ratio between the number of objects bought with the given money & the total number of objects bought) x: the independent variable ...
0
votes
0answers
8 views

Caret: customizing feature selection using matrix-wise operations [migrated]

Short question: is it possible to use matrix-wise operations in caretSBF$score function? Motivation: When working with big matrices in R, operations that work natively matrix-wise [e.g. rowMeans(X) ...
2
votes
1answer
54 views

chi-squared test when variables dependent

For a square matrix, is it appropriate to use a chi-squared distribution when each level of the variables are assumed to have the same overall frequency? Specifically, I'm analyzing a dataset of the ...
0
votes
0answers
9 views

Regsubsets “Linear Dependencies Found” [on hold]

I've recently been getting used to using the leaps library in R, and the regsubsets method ...
0
votes
1answer
33 views

Calculate required sample size with R with known power and ratio of n1 to n2

If I know that d=0.8, sig.level=0.05, power = 0.8, ...
0
votes
0answers
11 views

Parallel multi-dimensional numerical integration in R

I am working on a problem that needs a numerical integration of a bivariate function, where each evaluation of the function takes about 1 minute. Since numerical integration on a single core would ...
2
votes
0answers
78 views

Machine Learning Algorithms, Depth of Understanding Vs Number of algorithms, [migrated]

Recently i was introduced to the field of Data Science (its been 6 months approx),and i started the journey with Machine Learning Course by Andrew Ng and post that started working on the Data Science ...
0
votes
0answers
30 views

Plotting histogram in R, error on stat=“bin”

I'm trying to plot day against number of migrations as a histogram in R, but I'm coming up with this error message: ...
2
votes
1answer
42 views

How are the p-values in the glmer (lme4) output calculated?

The output of models built using the glmer function in the package lme4 automatically includes p-values. What method does lme4 use to calculate these p-values? I can't seem to find this information ...
0
votes
0answers
27 views

data transponse in R [on hold]

sc_id sc_name testId Class_id subject marks SC_1 NET tst_1 cls_1 Mathematics 3 SC_1 NET tst_1 cls_1 Zoology 4 SC_1 NET tst_1 cls_1 ...
1
vote
1answer
57 views

Logistic Regression Odds Interpret

I was analyzing the different treatments applied to products. It started out with a a plethora of variables but I came to the conclusion that I can essentially only control the treatment applied so I ...
2
votes
1answer
25 views

When to use zero-inflated poisson regression and negative binomial distribution

I have a fairly simple dataset looking at the relationship between the first nesting date of a bird in a given year (Date) and the birds overall fledgling production from that year (Fledge; count data ...
2
votes
1answer
16 views

Overfitting with low test error

I have an ensemble of models that yields overfitting by some models by looking at the differentce between training and test error and also overfits in the combined ensemble of models providing a very ...
2
votes
3answers
211 views

Normal approximation for large data set?

I have a dataset that is highly skewed. See image below: When I transform the data I get the following histogram that makes it look normal: This data however is not normal. I get a p-value of ...
2
votes
1answer
37 views

Interpreting intercept for the log model in linear regression in R for small predictor

I have a dataset. Assume that y is the dependent variable and x is the independent variable. My goals for this analysis is mainly on the following hypothesis: Expecting x=0 to imply y=0 Expecting ...
1
vote
2answers
20 views

Mann-Whitney/Wilcoxon rank sum test in R with a table of tallies

I have a 10 treatments, 5 samples per treatment, and the result of each treatment is ranked on a ordinal scale: Poor, Fair, Moderate, Good, Excellent. I have the data tallied up so I have the total ...
0
votes
0answers
5 views

Efficient programming to overcome memory problem in R [migrated]

I have a function that calculates an index in R for a matrix of binary data. The function is: ...
1
vote
0answers
7 views

Plotting fraction of NAs of a data frame [migrated]

Does anyone know how to plot the graphs of figure 23.1 of the example chapter of Steyerberg's book? The R-function is called "na.plot2" and Displays for example the fraction of missing values in data ...
0
votes
1answer
27 views

Interaction terms and effect sizes in multiple regression

I know there are similar questions on here, but I can't quite find an answer that covers all of what I need. I am running multiple regression in r with two predictor variables and sometimes an ...
0
votes
0answers
12 views

TBATS missing value error

I used tbats to find the best fit model to a 3 years of daily data. It couldnt find a model and showed the following error: " Missing values encountered. Using longest contiguous portion of time ...
1
vote
0answers
36 views

chisq.test with R

I want to do a Goodness-of-Fit test of my data and the Weibull-distribution. I have estimated the Weibull distribution using the survreg-function in R. Now I want ...
0
votes
0answers
11 views

How do I add spaces in between the labels on the y axis as well as move the y axis label to the far left so it wont clash with the text [on hold]

How do I add spaces between the labels on the y axis as well as move the y axis label to the far left to avoid clashing as can be seen in the image below. The programme I am using is R. Please help! ...
1
vote
1answer
21 views

Mixed ANOVA post hoc analysis (and multiple comparisons)

I have a set of 12 subjects: 6 administred with drug A and 6 with drug B. For each subject two time-points have been collected (before and after drug treatment) for each analyte (over 6000). I had a ...
0
votes
0answers
5 views

model average predictions in MuMIn [on hold]

This code is taken from the MuMIn package: ...
0
votes
0answers
20 views

Non-Parametric Density estimation with a positive variable [duplicate]

I’m struggling to find a way to represent a kernel density estimation with a nonnegative random variable. I have read a couple of articles tackling this issue; however I couldn’t implement it in R. I ...
0
votes
0answers
20 views

Problem in creating neighbors,area and perimeter in spatial econometrics using R [migrated]

I’m working on a spatial cross section model with R-programming-language. I’m running these codes which refers to ...
0
votes
0answers
17 views

Covariance Matrix using Delta Method

I am trying to get the variance-covariance matrix of a transformation using the Delta Method. Originally, I have coefficients (let's call them X1, X2, etc...) and their variance-covariance matrix. ...
0
votes
0answers
12 views

How to apply a set of statistical methods to each of the clusters obtained using a specific clustering method

Suppose I have generated 2 to 10 clustering solutions and found that 4 is the optimum number of clustering solution for hierarchical clustering. Now I wanted to apply a variable selection method ...
0
votes
0answers
11 views

Storing a kd-tree

I am trying to create a kd-tree using FNN package in R. get.knnx() usually computes kd_tree whenever a new search point is encountered. My problem statement is to store the kd tree for a set of ...
0
votes
0answers
12 views

About Hypothesis Test In Spatial Regression

I'm doing estimation of spatial lag/error model using R package "spreg"/"spdep". But I can't find any method to do hypothesis test after regression. For example, I want to test whether two ...
0
votes
0answers
33 views

R: Prediction using glm() [migrated]

I am using glm() function in R with link= log to fit my model. I read on various websites that fitted() returns the value which we can compare with the original data as compared to the predict(). I ...
0
votes
1answer
33 views

backward selection multivariate analysis usind R

I want to perform an exploratory Cox regression analysis of medical data using R. I am practicing using the pbc data from the survival function. How would you recommand performing a backward ...