Hello,
Is there a way to add a new variable on Stata that has different dimensions than the dataset that is in use, without first clearing the variable list?
For example,
Code:
use pharmacy_small
// calculate probability of each class on the test set
// '[:, 1]' at the end extracts the probability for each pharmacy to be under compliance
python: Y_mnb_score = mnb.fit(X_train, np.ravel(Y_train)).predict_proba(X_test)[:, 1]
// transfer the python variables Y_mnb_score as a Stata variable
python: Data.setObsTotal(len(Y_mnb_score))
python: Data.addVarFloat('mnbScore')
python: Data.store(var = 'mnbScore', obs = None, val = Y_mnb_score) // error: 'number of observations to set exceeds the limit of observations'
The error doesn't pop up when I first clear off the variables from the pharmacy_small data set and then execute the lines of python codes on Stata, but when I try to execute the python portion without first clearing out the dataset pharmacy_small, the error appears. I think the error pops up because the dimension of the variable 'mnbScore' that I am trying to add does not match with the dimension of the variables from the pharmacy_small dataset.
Is there a way to add a new variable on Stata that has different dimensions than the dataset that is in use, without first clearing the variable list?
Thank you,
Related Posts with Adding a new variable on Stata that has different dimensions than the variables from a dataset that is in use
Averages depending on dummy-value (RESHAPE?)Hi everyone, I have panel data in long format, grouped by ID & Age (in days). Additionally, I ha…
Selecting a sub-sample of a survival dataset, such that the mortality rate (-strate-) in the selected sub-sample achieves a certain targetStata MP 14.2, OSX 10.15.4 I am looking for an approach, be it by simulation or other, that will he…
Gsem function and Xt ?Dear honourable members, I am running a longitudinal data analysis using the gsem command according…
graph constant variablesHi, for example i have 3 variables with constans and i want to graph a line that follows each consta…
ivreg2 exogeneity test vs. biprobit exogeneity test, contradictory resultsHello Stata Listers, I am using Stata 15.1. My dependent variable is nonreceipt of a measles, mumps…
Subscribe to:
Post Comments (Atom)
0 Response to Adding a new variable on Stata that has different dimensions than the variables from a dataset that is in use
Post a Comment