Dear All: Can the *Coefficient of Partial Determination* in multiple linear regression be computed in R? If so, could you please let me know how? fullmodel <- lm(Price ~ Size + Lotsize + Bedrooms + Bathrooms) *I found this in the internet, but I could find the package "rms"* *library(rms) # will also load Hmisc* *fit <- ols(y ~ x1 + x2, data=bf.dat) * *plt <- plot(anova(fit), what='partial R2')* *plt* Here is part of the data as an example: --------------------------------------------------- Taxes Bedrooms Bathrooms Price Size Lotsize 296 3 3 795000 2371 5850 242 4 3 399000 2818 4000 242 4 3 545000 3032 3060 222 4 4 909000 3540 6650 222 3 1 109900 1249 6360 222 3 3 324900 1800 4160 311 4 2 192900 1603 3880 311 3 2 215000 1450 4160 311 4 3 999000 3360 4800 311 3 2 319000 1323 5500 311 3 2 350000 1750 7200 311 3 2 249000 1400 3000 311 2 2 299000 1257 1700 307 3 2 235900 1400 2880 307 3 2 348000 1600 3600 307 4 3 314000 1794 3185 307 4 2 399000 1850 3300 307 3 3 599000 2950 5200 307 3 2 299000 1719 3450 307 3 3 425000 1472 3986 307 4 3 1100000 4168 4785 307 3 3 1500000 3880 4510 307 2 1 110000 1000 4000 307 3 2 200000 1139 3934 307 3 1 134900 1080 4960 307 4 3 250000 2000 3000 307 3 4 950000 1920 3800 307 4 2 239950 1348 4960 307 3 2 170000 1280 3000 307 3 2 285000 2400 4500 307 3 3 279000 1700 3500 307 3 2 219000 1600 3500 307 3 2 155000 1050 4000 307 3 2 389000 1415 4500 307 3 1 340000 1110 6360 279 2 1 95000 797 4500 279 2 2 140000 1100 4032 279 3 3 1100000 2602 5170 279 4 3 360000 2351 5400 252 3 3 415000 1350 3150 252 4 2 250000 1206 3745 233 3 3 559000 2628 4520 233 3 3 525000 2365 4640 233 3 3 779000 2990 8580 233 3 2 595000 1750 2000 233 4 5 1150000 5500 2160 233 3 2 550000 1852 3040 233 3 2 500000 2100 3090 233 4 3 279000 2580 4960 233 4 2 375000 1963 3350 243 3 3 330000 1900 5300 243 3 3 199000 1450 4100 243 2 2 165000 1000 9166 243 4 3 1399000 6500 4040 469 3 2 255000 1218 3630 226 2 2 325000 893 3620 Thank you very much for your help and support abou ______________________ AbouEl-Makarim Aboueissa, PhD University of Southern Maine Department of Mathematics and Statistics [[alternative HTML version deleted]]
> On Mar 1, 2017, at 9:57 AM, AbouEl-Makarim Aboueissa <abouelmakarim1962 at gmail.com> wrote: > > Dear All: > > Can the *Coefficient of Partial Determination* in multiple linear > regression be computed in R? If so, could you please let me know how? > > > fullmodel <- lm(Price ~ Size + Lotsize + Bedrooms + Bathrooms)Partial R^2's should just be a simple calculation of a ratio of sums of squares. After searching on that 'fullmodel" construction I see that a similar problem was posed for college coursework: houses = read.csv("http://home.cc.umanitoba.ca/~godwinrt/3180/data/houseprice.csv") (Homework is not considered on-topic for r-help.) Perhaps you need to learn to search: sos::findFn("coefficient of partial determination") ... finds one. sos::findFn("partial R^2") ... finds both that one and another Code can be found searching the archives: http://markmail.org/search/?q=list%3Aorg.r-project.r-help+coefficient+of+partial+determination This had a particularly compact and well commented example: http://markmail.org/search/?q=list%3Aorg.r-project.r-help+coefficient+of+partial+determination#query:list%3Aorg.r-project.r-help%20coefficient%20of%20partial%20determination+page:1+mid:s7gcefsew5cce46q+state:results> > > *I found this in the internet, but I could find the package "rms"*I'm assuming you meant to type "couldn't", although that is rather surprising since it is a well-established and respected package: https://cran.r-project.org/web/packages/rms/index.html> > *library(rms) # will also load Hmisc* > > *fit <- ols(y ~ x1 + x2, data=bf.dat) * > > *plt <- plot(anova(fit), what='partial R2')*The asterisks would need to be removed but generally you will also need to use a call to `datadist` and `options` when using the rms/Hmisc suite of functions. The book that supports that package is excellent. Hope this helps; David.> > *plt* > > > > Here is part of the data as an example: > --------------------------------------------------- > > Taxes Bedrooms Bathrooms Price Size Lotsize > 296 3 3 795000 2371 5850 > 242 4 3 399000 2818 4000 > 242 4 3 545000 3032 3060 > 222 4 4 909000 3540 6650 > 222 3 1 109900 1249 6360 > 222 3 3 324900 1800 4160 > 311 4 2 192900 1603 3880 > 311 3 2 215000 1450 4160 > 311 4 3 999000 3360 4800 > 311 3 2 319000 1323 5500 > 311 3 2 350000 1750 7200 > 311 3 2 249000 1400 3000 > 311 2 2 299000 1257 1700 > 307 3 2 235900 1400 2880 > 307 3 2 348000 1600 3600 > 307 4 3 314000 1794 3185 > 307 4 2 399000 1850 3300 > 307 3 3 599000 2950 5200 > 307 3 2 299000 1719 3450 > 307 3 3 425000 1472 3986 > 307 4 3 1100000 4168 4785 > 307 3 3 1500000 3880 4510 > 307 2 1 110000 1000 4000 > 307 3 2 200000 1139 3934 > 307 3 1 134900 1080 4960 > 307 4 3 250000 2000 3000 > 307 3 4 950000 1920 3800 > 307 4 2 239950 1348 4960 > 307 3 2 170000 1280 3000 > 307 3 2 285000 2400 4500 > 307 3 3 279000 1700 3500 > 307 3 2 219000 1600 3500 > 307 3 2 155000 1050 4000 > 307 3 2 389000 1415 4500 > 307 3 1 340000 1110 6360 > 279 2 1 95000 797 4500 > 279 2 2 140000 1100 4032 > 279 3 3 1100000 2602 5170 > 279 4 3 360000 2351 5400 > 252 3 3 415000 1350 3150 > 252 4 2 250000 1206 3745 > 233 3 3 559000 2628 4520 > 233 3 3 525000 2365 4640 > 233 3 3 779000 2990 8580 > 233 3 2 595000 1750 2000 > 233 4 5 1150000 5500 2160 > 233 3 2 550000 1852 3040 > 233 3 2 500000 2100 3090 > 233 4 3 279000 2580 4960 > 233 4 2 375000 1963 3350 > 243 3 3 330000 1900 5300 > 243 3 3 199000 1450 4100 > 243 2 2 165000 1000 9166 > 243 4 3 1399000 6500 4040 > 469 3 2 255000 1218 3630 > 226 2 2 325000 893 3620 > > > > Thank you very much for your help and support > > abou > ______________________ > AbouEl-Makarim Aboueissa, PhD > University of Southern Maine > Department of Mathematics and Statistics > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius Alameda, CA, USA
The rms and Hmisc packages can be found on CRAN. Just run install packages from the console menu. Dan Daniel Nordlund, PhD Research and Data Analysis Division Services & Enterprise Support Administration Washington State Department of Social and Health Services> -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of AbouEl- > Makarim Aboueissa > Sent: Wednesday, March 01, 2017 9:57 AM > To: R-help at r-project.org > Subject: [R] Coefficient of Partial Determination > > Dear All: > > Can the *Coefficient of Partial Determination* in multiple linear > regression be computed in R? If so, could you please let me know how? > > > fullmodel <- lm(Price ~ Size + Lotsize + Bedrooms + Bathrooms) > > > *I found this in the internet, but I could find the package "rms"* > > *library(rms) # will also load Hmisc* > > *fit <- ols(y ~ x1 + x2, data=bf.dat) * > > *plt <- plot(anova(fit), what='partial R2')* > > *plt* > > > > Here is part of the data as an example: > --------------------------------------------------- > > Taxes Bedrooms Bathrooms Price Size Lotsize > 296 3 3 795000 2371 5850 > 242 4 3 399000 2818 4000 > 242 4 3 545000 3032 3060 > 222 4 4 909000 3540 6650 > 222 3 1 109900 1249 6360 > 222 3 3 324900 1800 4160 > 311 4 2 192900 1603 3880 > 311 3 2 215000 1450 4160 > 311 4 3 999000 3360 4800 > 311 3 2 319000 1323 5500 > 311 3 2 350000 1750 7200 > 311 3 2 249000 1400 3000 > 311 2 2 299000 1257 1700 > 307 3 2 235900 1400 2880 > 307 3 2 348000 1600 3600 > 307 4 3 314000 1794 3185 > 307 4 2 399000 1850 3300 > 307 3 3 599000 2950 5200 > 307 3 2 299000 1719 3450 > 307 3 3 425000 1472 3986 > 307 4 3 1100000 4168 4785 > 307 3 3 1500000 3880 4510 > 307 2 1 110000 1000 4000 > 307 3 2 200000 1139 3934 > 307 3 1 134900 1080 4960 > 307 4 3 250000 2000 3000 > 307 3 4 950000 1920 3800 > 307 4 2 239950 1348 4960 > 307 3 2 170000 1280 3000 > 307 3 2 285000 2400 4500 > 307 3 3 279000 1700 3500 > 307 3 2 219000 1600 3500 > 307 3 2 155000 1050 4000 > 307 3 2 389000 1415 4500 > 307 3 1 340000 1110 6360 > 279 2 1 95000 797 4500 > 279 2 2 140000 1100 4032 > 279 3 3 1100000 2602 5170 > 279 4 3 360000 2351 5400 > 252 3 3 415000 1350 3150 > 252 4 2 250000 1206 3745 > 233 3 3 559000 2628 4520 > 233 3 3 525000 2365 4640 > 233 3 3 779000 2990 8580 > 233 3 2 595000 1750 2000 > 233 4 5 1150000 5500 2160 > 233 3 2 550000 1852 3040 > 233 3 2 500000 2100 3090 > 233 4 3 279000 2580 4960 > 233 4 2 375000 1963 3350 > 243 3 3 330000 1900 5300 > 243 3 3 199000 1450 4100 > 243 2 2 165000 1000 9166 > 243 4 3 1399000 6500 4040 > 469 3 2 255000 1218 3630 > 226 2 2 325000 893 3620 > > > > Thank you very much for your help and support > > abou > ______________________ > AbouEl-Makarim Aboueissa, PhD > University of Southern Maine > Department of Mathematics and Statistics > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.