使用REAT包betaconv.ols函数时出现unused argument (output.results = TRUE)错误的解决求助
unused argument (output.results = TRUE) Error in REAT::betaconv.ols Hey there! Let's break down what's going on here and fix that error you're seeing.
Why the Error Happens
The error message clearly states that output.results = TRUE is an unused argument—and that's because the betaconv.ols function from the REAT package doesn't actually have this parameter.
To confirm this, you can check the official documentation for the function anytime by running:
?betaconv.ols
Looking at the parameter list, you'll see the function only accepts:
y0: Initial period income/value (yourt2000column)t0: Initial year (2000)yT: Final period income/value (yourt2019column)tT: Final year (2019)robust: Logical for robust standard errors (default:FALSE)plot: Logical to generate a convergence scatter plot (default:FALSE)
How to Get the Results You Need
Instead of using the non-existent output.results parameter, you just need to assign the function's output to a variable, then view or manipulate that variable. Here's how to do it with your data:
Run the model and save the results
# Load the REAT package first if you haven't library(REAT) # Run the beta convergence model and store results convergence_results <- betaconv.ols(GDP_NUTS2$t2000, 2000, GDP_NUTS2$t2019, 2019)View the full results
Just print the saved object to see all the key output (coefficients, p-values, convergence rate, half-life, etc.):print(convergence_results)Extract specific components
If you want to pull out specific values (like the convergence coefficient or p-value), you can access them directly from the result object:# Get the regression coefficients convergence_results$coefficients # Get p-values for the coefficients convergence_results$p.values # Get the calculated convergence rate (λ) convergence_results$lambda # Get the half-life of convergence convergence_results$half.lifeAdd a visualization (optional)
If you want to see a scatter plot of initial vs. growth rates (with the regression line), use theplotparameter:betaconv.ols(GDP_NUTS2$t2000, 2000, GDP_NUTS2$t2019, 2019, plot = TRUE)
Quick Test with Your Sample Data
To make sure this works, let's test it with the first 5 rows of your dataset:
# Create the sample data frame GDP_NUTS2_sample <- structure(list(Regiao = c("T", "N", "Ag", "C", "AML"), t2000 = c(12529.42964, 10054.60679, 13045.59069, 10621.51789, 18104.36306), t2019 = c(20755.955, 17712.44223, 23145.30242, 18045.54697, 26970.71178)), row.names = c(NA, -5L), class = c("tbl_df", "tbl", "data.frame")) # Run the model sample_results <- betaconv.ols(GDP_NUTS2_sample$t2000, 2000, GDP_NUTS2_sample$t2019, 2019) # Print results print(sample_results)
This will output the full convergence analysis without any errors.
内容的提问来源于stack exchange,提问作者Cláudio Siva

