Error in plot.new() : figure margins too large
Full error:
#Question
Fit the regression model and calculate the dfbetas value of each sample and the optimal dfbetas threshold. Finally, visualize the impact of each sample on each predictive variable;
#fit a regression model
model <- lm(mpg~disp+hp, data=mtcars)
#view model summary
summary(model)
#calculate DFBETAS for each observation in the model
dfbetas <- as.data.frame(dfbetas(model))
#display DFBETAS for each observation
dfbetas
#find number of observations
n <- nrow(mtcars)
#calculate DFBETAS threshold value
thresh <- 2/sqrt(n)
thresh
#specify 2 rows and 1 column in plotting region
#dev.off()
#par(mar = c(1, 1, 1, 1))
par(mfrow=c(2,1))
#plot DFBETAS for disp with threshold lines
plot(dfbetas$disp, type='h')
abline(h = thresh, lty = 2)
abline(h = -thresh, lty = 2)
#plot DFBETAS for hp with threshold lines
plot(dfbetas$hp, type='h')
abline(h = thresh, lty = 2)
abline(h = -thresh, lty = 2)
#Solution
par(mar = c(1, 1, 1, 1))
#fit a regression model
model <- lm(mpg~disp+hp, data=mtcars)
#view model summary
summary(model)
#calculate DFBETAS for each observation in the model
dfbetas <- as.data.frame(dfbetas(model))
#display DFBETAS for each observation
dfbetas
#find number of observations
n <- nrow(mtcars)
#calculate DFBETAS threshold value
thresh <- 2/sqrt(n)
thresh
#specify 2 rows and 1 column in plotting region
#dev.off()
par(mar = c(1, 1, 1, 1))
par(mfrow=c(2,1))
#plot DFBETAS for disp with threshold lines
plot(dfbetas$disp, type='h')
abline(h = thresh, lty = 2)
abline(h = -thresh, lty = 2)
#plot DFBETAS for hp with threshold lines
plot(dfbetas$hp, type='h')
abline(h = thresh, lty = 2)
abline(h = -thresh, lty = 2)
Full Error Message:
> par(mfrow=c(2,1))
>
> #plot DFBETAS for disp with threshold lines
> plot(dfbetas$disp, type=’h’)
Error in plot.new() : figure margins too large
> abline(h = thresh, lty = 2)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, …) :
plot.new has not been called yet
> abline(h = -thresh, lty = 2)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, …) :
plot.new has not been called yet
>
> #plot DFBETAS for hp with threshold lines
> plot(dfbetas$hp, type=’h’)
Error in plot.new() : figure margins too large
> abline(h = thresh, lty = 2)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, …) :
plot.new has not been called yet
> abline(h = -thresh, lty = 2)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, …) :
plot.new has not been called yet
Read More:
- How to Solve Opencv Error: CPP: 1557 error
- How to Solve Keras calls plot_model error
- [Solved] SOLVE/lcloos: Inversion error in LCNORM(2)
- R Language Error: variable does not have limits defined by datadist
- [Solved] ValueError: the indices for endog and exog are not aligned
- [Solved] unity EditorGUILayer dynamic drawing scrolling list error
- [Solved] Runtimeerror during dcgan training: found dtype long but expected float
- [Solved] MindSpore Error: “ValueError:invalid literal for int()with base10’the’
- [Solved] Android Studio Error: The binary version of its metadata is 1.5.1, expected version is 1.1.15.
- PyCharm Error: RuntimeError: CUDA out of memory [How to Solve]
- [Solved] MindSpore Error: Should not use Python in runtime
- [Solved] adb Error: error: no devices/emulators found error: cannot connect to daemon
- Tensorflow error: attributeerror: module ‘tensorflow_ API. V1. Train ‘has no attribute’ summarywriter ‘
- Internalerror: GPU sync failed error (How to Solve)
- How to Fix KeyError: ‘plotly_domain’
- [Solved] pytorch Load Error: “RuntimeError: Error(s) in loading state_dict for Sequential:”
- [Solved] TensorFlow severing Container Creat Error: failed: Out of range: Read less bytes than requested
- Laravel model save if the table has no ID field Error [How to Solve]
- [Solved] Postman Error: Unsupported Media Type
- [Solved] ERROR #42601 syntax error at or near “)“