cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-615040%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20calcule%20el%20%C3%A1rea%20bajo%20la%20curva%20por%20integraci%C3%B3n%20y%20luego%20complete%20el%20resultado%20en%20una%20nueva%20columna.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-615040%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIntente%20verificar%20c%C3%B3mo%20se%20ve%20la%20f%C3%B3rmula%20que%20genera%20JMP%2C%20lo%20m%C3%A1s%20probable%20es%20que%20reemplace%20su%20tiempo%20con%3A%20tiempo%2C%20as%C3%AD%20que%20use%20un%20nombre%20diferente%20para%20la%20variable%20y%20la%20expresi%C3%B3n%20interna%20que%20las%20columnas%20en%20su%20tabla%20de%20datos%20(y%20posiblemente%20envu%C3%A9lvala%20dentro%20Como%20constante%20())%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EAs%20Constant(%0A%20resp%20%3D%20Expr(a%20*%20a)%3B%0A%20area%20%3D%20Integrate(resp%2C%20a%2C%20Col%20Min(%3Atime)%2C%20Col%20Max(%3Atime))%3B%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-615213%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20calcule%20el%20%C3%A1rea%20bajo%20la%20curva%20por%20integraci%C3%B3n%20y%20luego%20complete%20el%20resultado%20en%20una%20nueva%20columna.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-615213%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%C2%BFQu%C3%A9%20pasa%20si%20la%20expresi%C3%B3n%20utilizada%20por%20Integrar%20debe%20extraerse%20de%20la%20f%C3%B3rmula%20en%20una%20columna%2C%20por%20ejemplo%2C%20para%20Integrar%20usando%20una%20f%C3%B3rmula%20de%20un%20ajuste%20polinomial%3F%3C%2FP%3E%3CP%3EEn%20la%20siguiente%20tabla%2C%20la%20f%C3%B3rmula%20en%20la%20columna%20predictora%20usar%C3%ADa%20%3Atime%20y%20%3Aresponse.%20%C2%BFExiste%20una%20sintaxis%20r%C3%A1pida%20para%20reemplazar%20los%20nombres%20de%20las%20columnas%20con%20nuevas%20variables%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F51369iE64A7D6BF48830D5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22GroupSquareWolf_0-1679436129378.png%22%20alt%3D%22GroupSquareWolf_0-1679436129378.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-615282%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20calcule%20el%20%C3%A1rea%20bajo%20la%20curva%20por%20integraci%C3%B3n%20y%20luego%20complete%20el%20resultado%20en%20una%20nueva%20columna.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-615282%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ENo%20usar%C3%ADa%20f%C3%B3rmulas%20si%20solo%20desea%20replicar%20el%20mismo%20valor%20en%20cada%20fila%20(en%20la%20mayor%C3%ADa%20de%20los%20casos%2C%20es%20mejor%20usar%20%26lt%3B%26lt%3B%20Establecer%20cada%20valor%20en%20casos%20como%20este).%3C%2FP%3E%0A%3CP%3ENo%20estoy%20seguro%20de%20si%20hay%20alguna%20sintaxis%20r%C3%A1pida%20para%20reemplazar%20los%20nombres%20de%20las%20columnas%20con%20nuevas%20variables%2C%20pero%20char%2Bsubstitute%2Bparse%2Bexpressions%20es%20una%20opci%C3%B3n%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Adt%20%3D%20New%20Table(%22Untitled%22%2C%0A%20Add%20Rows(4)%2C%0A%20Compress%20File%20When%20Saved(1)%2C%0A%20New%20Column(%22t%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Set%20Values(%5B1%2C%202%2C%203%2C%204%5D))%2C%0A%20New%20Column(%22r%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%22Best%22%2C%2012)%2C%20Formula(%3At%20%5E%202))%0A)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22i%22%2C%20Numeric%2C%20Continuous%2C%20%26lt%3B%26lt%3B%20Set%20Each%20Value(%0A%20f%20%3D%20Eval%20Expr(Expr(Parse(Substitute(Char(Column(dt%2C%20%22r%22)%20%26lt%3B%26lt%3B%20get%20formula)%2C%20%22%3A%22%2C%20%22%22))))%3B%0A%20Integrate(f%2C%20t%2C%20Col%20Min(%3At)%2C%20Col%20Max(%3At))%3B%0A))%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-615023%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3Ecalcule%20el%20%C3%A1rea%20bajo%20la%20curva%20por%20integraci%C3%B3n%20y%20luego%20complete%20el%20resultado%20en%20una%20nueva%20columna.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-615023%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEn%20esta%20tabla%20de%20datos%20de%20ejemplo%2C%20la%20respuesta%20se%20define%20mediante%20la%20f%C3%B3rmula%3A%20respuesta%20%3D%20tiempo*tiempo%3C%2FP%3E%3CP%3EMe%20gustar%C3%ADa%20calcular%20el%20%22%C3%A1rea%20bajo%20la%20curva%22%20(AUC)%20por%20integraci%C3%B3n%20usando%20la%20f%C3%B3rmula%20definida%20en%20la%20columna%20de%20respuesta%20y%20el%20rango%20de%20tiempo%20definido%20en%20la%20columna%3A%20tiempo%2C%20luego%20completar%20el%20resultado%20en%20una%20nueva%20columna%20en%20la%20tabla%20de%20datos%20(por%20%22rellenar%20%22Quiero%20decir%20que%20todas%20las%20filas%20tienen%20el%20valor%20del%20AUC%20calculado).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ES%C3%A9%20que%20puedo%20usar%20el%20siguiente%20script%20para%20calcular%20el%20AUC%20y%20el%20resultado%20del%20%C3%A1rea%20es%2041333.%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eresp%20%3D%20Expr%20(time%20*%20time)%3B%0A%0Aarea%20%3D%20Integrate%20(resp%2C%20time%2C%2010%2C%2050)%3B%0A%0Ashow%20(area)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3ESin%20embargo%2C%20cuando%20trat%C3%A9%20de%20completar%20el%20resultado%20AUC%20(todas%20las%20filas%20tienen%20el%20valor%20de%2041333)%3CSPAN%3E%20en%20la%20columna%20%3AIntegrar%3C%2FSPAN%3E%3CSPAN%3E%20mediante%20el%20uso%20de%20la%20f%C3%B3rmula%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EIntegrar(%20%3Arespuesta%2C%20%3Atiempo%2C%20Col%20M%C3%A1ximo(%20%3Atiempo%20)%2C%20Col%20M%C3%ADnimo(%20%3Atiempo%20)%20)%3C%2FP%3E%3CP%3Een%20lugar%20de%20completar%20el%20resultado%2041333%2C%20la%20f%C3%B3rmula%20calcul%C3%B3%20el%20resultado%20en%20funci%C3%B3n%20del%20valor%20definido%20de%3A%20tiempo%20en%20cada%20fila.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%C2%BFCu%C3%A1l%20es%20la%20forma%20correcta%20de%20escribir%20la%20f%C3%B3rmula%20para%20que%20la%20columna%20%3AIntegrate%20se%20llene%20con%20el%20resultado%2041333%3F%3C%2FP%3E%3CP%3ES%C3%A9%20que%20podr%C3%ADa%20usar%20JSL%20para%20crear%20una%20nueva%20tabla%20de%20datos%20y%20luego%20unirme%20al%20resultado%2C%20pero%20preferir%C3%ADa%20hacerlo%20dentro%20de%20la%20misma%20tabla%20de%20datos.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%C2%A1Gracias!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22GroupSquareWolf_0-1679416641928.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679416641928.png%22%20style%3D%22width%3A%20293px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22GroupSquareWolf_0-1679416641928.png%22%20style%3D%22width%3A%20293px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F51343i47B15125FBF81FE5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22GroupSquareWolf_0-1679416641928.png%22%20alt%3D%22GroupSquareWolf_0-1679416641928.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-615023%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EAutomatizaci%C3%B3n%20y%20secuencias%20de%20comandos%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Choose Language Hide Translation Bar
GroupSquareWolf
Level III

calculate area under the curve by integration then populate the result in a new column.

In this example datatable, response is defined by fomula:  response = time*time

I would like to calculate "area under the curve" (AUC) by integration using the fomula defined in the response column and the time range defined in the :time column, then populate the result in a new column in the datatable (by "populate" I mean all rows have the value of the calculated AUC).

 

I know I can use the following script to calculate the AUC, and the result of area is 41333.

resp = Expr (time * time);

area = Integrate (resp, time, 10, 50);

show (area);

However, when I tried to populate the AUC result (all rows have the value of 41333) in the :Integrate column by using formula: 

      Integrate( :response, :time, Col Maximum( :time ), Col Minimum( :time ) )

instead of populating the result 41333 , the formula calculated the result based on the defined value of : time in each row. 

 

What is the correct way to write the formula so that the :Integrate column is populated with the result 41333?

I know I could use JSL to create a new datatable and then join the result but would prefer to do this within the same datatable.

 

Thanks!

 

GroupSquareWolf_0-1679416641928.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: calculate area under the curve by integration then populate the result in a new column.

I wouldn't use formulas if you just want to replicate same value to each row (in most cases it is better to use << Set Each Value in cases like this).

I'm not sure if there is any quick syntax to replace column names with new variables, but char+substitute+parse+expressions is one option

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(4),
	Compress File When Saved(1),
	New Column("t", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4])),
	New Column("r", Numeric, "Continuous", Format("Best", 12), Formula(:t ^ 2))
);

dt << New Column("i", Numeric, Continuous, << Set Each Value(
	f = Eval Expr(Expr(Parse(Substitute(Char(Column(dt, "r") << get formula), ":", ""))));
	Integrate(f, t, Col Min(:t), Col Max(:t));
));
-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: calculate area under the curve by integration then populate the result in a new column.

Try checking out how the formula JMP generates does look like, it will most likely replace your time with :time so use different name for the variable and inside expression than columns in your data table (and possibly wrap it inside As Constant())

As Constant(
	resp = Expr(a * a);
	area = Integrate(resp, a, Col Min(:time), Col Max(:time));
)
-Jarmo
GroupSquareWolf
Level III

Re: calculate area under the curve by integration then populate the result in a new column.

What if the expression used by Integrate needs to be extracted from the formula in a column, for example to Integrate using a formula from a polynomial fit.

In the table below, the formula in the predictor column would use  :time and :response. Is there a quick syntax to replace the column names with new variables?

 

GroupSquareWolf_0-1679436129378.png

 

jthi
Super User

Re: calculate area under the curve by integration then populate the result in a new column.

I wouldn't use formulas if you just want to replicate same value to each row (in most cases it is better to use << Set Each Value in cases like this).

I'm not sure if there is any quick syntax to replace column names with new variables, but char+substitute+parse+expressions is one option

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(4),
	Compress File When Saved(1),
	New Column("t", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4])),
	New Column("r", Numeric, "Continuous", Format("Best", 12), Formula(:t ^ 2))
);

dt << New Column("i", Numeric, Continuous, << Set Each Value(
	f = Eval Expr(Expr(Parse(Substitute(Char(Column(dt, "r") << get formula), ":", ""))));
	Integrate(f, t, Col Min(:t), Col Max(:t));
));
-Jarmo