Tipping point code from R to MATLAB
7 views (last 30 days)
Show older comments
Hi, I have a R code and SAS code for tipping point analysis. Please help me to do this analysis in MATLAB. https://cran.r-project.org/web/packages/TippingPoint/vignettes/TippingPoint.html Attached is SAS code and the link is from R. I am giving the R code in steps in the following. Please help me out
1. library(TippingPoint)
- Load the dataset
data(tippingdata)
- Show the first 6 rows of the data
head(tippingdata)
## continuous binary educ female treat
## 1 119.7820 1 12 0 1
## 2 117.7729 0 16 0 1
## 3 124.7833 0 12 1 1
## 4 123.3546 0 12 1 1
## 5 124.6611 0 12 1 1
## 6 NA 1 15 0 1
Basic Plot: ## for binary outcome # Using `estimate` TippingPoint(outcome=tippingdata$binary,
treat= tippingdata$treat,group.infor=TRUE,
plot.type = "estimate",ind.values = TRUE,
impValuesT = NA, impValuesC = NA,
summary.type = "density", alpha = 0.95, S=1.5, n.grid = 100,
HistMeanT = c(0.38,0.4), HistMeanC = c(0.2,0.55))
2. # Using `p.value` with formula class
TippingPoint(binary~treat, data=tippingdata,
plot.type = "p.value",ind.values = TRUE,
impValuesT = NA, impValuesC = NA,
summary.type = "density", alpha = 0.95, S=1.5, n.grid = 100,
HistMeanT = c(0.38,0.4), HistMeanC = c(0.2,0.55))
3. # Using `both` TippingPoint(outcome=tippingdata$binary,treat= tippingdata$treat,
plot.type = "both",ind.values = TRUE,
impValuesT = NA, impValuesC = NA,
summary.type = "density", alpha = 0.95, S=1.5, n.grid = 100,
HistMeanT = c(0.38,0.4), HistMeanC = c(0.2,0.55))
4. # for continuous outcome TippingPoint(continuous~treat, data=tippingdata,
group.infor=TRUE, plot.type = "estimate",ind.values = TRUE,
impValuesT = NA, impValuesC = NA,
summary.type = "density", alpha = 0.95, S=1.5, n.grid = 100,
HistMeanT = c(120), HistMeanC = c(131,137))
5. TippingPoint(outcome=tippingdata$continuous,treat= tippingdata$treat,
plot.type = "p.value",ind.values = TRUE,
impValuesT = NA, impValuesC = NA,
summary.type = "density", alpha = 0.95, S=1.5, n.grid = 100,
HistMeanT = c(120), HistMeanC = c(131,137))
6.TippingPoint(outcome=tippingdata$continuous,treat= tippingdata$treat,
plot.type = "both",ind.values = TRUE,
impValuesT = NA, impValuesC = NA,
summary.type = "density", alpha = 0.95, S=1.5, n.grid = 100,
HistMeanT = c(120), HistMeanC = c(131,137))
4 Comments
Adam
on 8 Nov 2017
Time to do some reading and learning in that case! If you have no idea how either language works you won't get very far using the code even if someone does take their own time to convert it all for you! The Matlab help is very good to learn from.
Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!